Skip to the content of the web site.

Counting semaphores

The application of the equivalent of a counting semaphore to achieve synchronization, including mutual exclusion and serialization, is described in the RL-ARM user's guide under Semaphore Management Routines. In this implementation, the word send is used to describe the posting of the counting semaphore, as a signal is being sent to a task that is either waiting on or will wait on the given counting semaphore.

Note that no attempt is made to solve the priority inversion problem in semaphores. If priority inheritance is to be used, it is necessary to use the Mutex Management Routines routines.

To view the source code for the semaphore implementation, see Keil\ARM\RL\RTX\SRC\ARM\rt_Semaphore.c.

Note: if you are interestd at looking at the CMSIS-RTOS implementation of seamphores, please see the CMSIS-RTOS API page on semaphore management.

Unlike the Keil RTX RTOS, it includes functions for creating, waiting on, releasing and deleting semaphores. The Keil RTX RTOS likely assumes you are using their RTOS in a situation that does not require the dynamic creation and destruction of semaphores.

Note that the CMSIS-RTOS API is meant to be cross-platform for all Cortex-M processors. Consequently, the implementation is based strongly on using the pre-processor #define directive allowing for platform-specific implementations of these macros.