Skip to content

Commit 6b02cea

Browse files
committed
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++.
1 parent 226af54 commit 6b02cea

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

platform/mbed_retarget.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1014,6 +1014,11 @@ extern "C" void EvrRtxMutexError (osMutexId_t mutex_id, int32_t status)
10141014

10151015
extern "C" void EvrRtxSemaphoreError (osSemaphoreId_t semaphore_id, int32_t status)
10161016
{
1017+
// Ignore semaphore overflow, the count will saturate with a returned error
1018+
if (status == osRtxErrorSemaphoreCountLimit) {
1019+
return;
1020+
}
1021+
10171022
error("Semaphore %p error %i\r\n", semaphore_id, status);
10181023
}
10191024

rtos/Semaphore.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
namespace rtos {
2828

2929
Semaphore::Semaphore(int32_t count) {
30-
constructor(count, 1024);
30+
constructor(count, 0xffff);
3131
}
3232

3333
Semaphore::Semaphore(int32_t count, uint16_t max_count) {

0 commit comments

Comments
 (0)