From 6b02ceab5dda4f60078696f11dbc329a994434a8 Mon Sep 17 00:00:00 2001 From: Christopher Haster Date: Fri, 16 Jun 2017 13:36:47 -0500 Subject: [PATCH] rtos: Unbreak semaphore, trade assert for saturation with original limit Before rtx 5, the max count on semaphores was UINT16_MAX, aftewards it was decreased to 1024 with an assert on overflow. This is especially problematic for semaphores used for signaling, since there is no replacement currently available in C++. --- platform/mbed_retarget.cpp | 5 +++++ rtos/Semaphore.cpp | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/platform/mbed_retarget.cpp b/platform/mbed_retarget.cpp index a505d13ee9..f7bed54261 100644 --- a/platform/mbed_retarget.cpp +++ b/platform/mbed_retarget.cpp @@ -1014,6 +1014,11 @@ extern "C" void EvrRtxMutexError (osMutexId_t mutex_id, int32_t status) extern "C" void EvrRtxSemaphoreError (osSemaphoreId_t semaphore_id, int32_t status) { + // Ignore semaphore overflow, the count will saturate with a returned error + if (status == osRtxErrorSemaphoreCountLimit) { + return; + } + error("Semaphore %p error %i\r\n", semaphore_id, status); } diff --git a/rtos/Semaphore.cpp b/rtos/Semaphore.cpp index 4e2aa8b2ac..107dccb33f 100644 --- a/rtos/Semaphore.cpp +++ b/rtos/Semaphore.cpp @@ -27,7 +27,7 @@ namespace rtos { Semaphore::Semaphore(int32_t count) { - constructor(count, 1024); + constructor(count, 0xffff); } Semaphore::Semaphore(int32_t count, uint16_t max_count) {