Hello,
µVision V5.12, CMSIS OS RTX V4.75
It seemed to me, that a binary Semaphore does not work correctly with my test code. osSemaphoreWait returns a value of 4, but it is a binary semaphore. Do I missunderstand something?
// compile without optimizations, level 0. #include "cmsis_os.h" osSemaphoreDef(sema); osSemaphoreId sema; int main (void) { int32_t tokens; sema = osSemaphoreCreate(osSemaphore(sema),1); /* create binary sema max count of tokens should be 1 */ osSemaphoreRelease(sema); // try to increment sema osSemaphoreRelease(sema); // try to increment sema osSemaphoreRelease(sema); // try to increment sema tokens = osSemaphoreWait(sema,0); // the value of tokens is 4 after // execution, though I limited the sema counter to 1 token // is this a bug? }
Thanks for reply
Thomas
Hello Thomas,
this is a problem of API versus implementation. From the API it seems that the parameter count specifies the maximum number of available resources. In the CMSIS-RTOS RTX implementation it is used as an initial resource count number. It is not remembered as the maximum number of available resources. Thus, every call to osSemaphoreRelease increases the number of available resources. We will fix this in a future release (in the API and the implementation).
Kind regards,
Christopher
Thaks very much
We use osSemaphoreRelease everywhere. it's very important and urgent problem, I am wondering why keil does not release a new RTX kernel version as they promised!
View all questions in Keil forum