Arm Mbed OS support forum

Semaphore for thread access counting


implementations of semaphores often allow me to get the current number of acquisitions from different threads. Why am I not able to get the current count for mbed semaphores? Wouldn’t it be helpful to get the number of remaining threads that can enter the semaphore object?

Something like:
Semaphore sema(10);
sema.count(); // returns 1 or 9, depending on the implementation

Implementation would look like
uint16_t Semaphore::count()
return osSemaphoreGetCount(_id);


Thank you.