Real-Time Embedded Multithreading: Using ThreadX and ARM

ThreadX provides 32-bit counting semaphores with counts that range in value from 0 to 2 32 1, or 4,294,967,295 (inclusive). There are two operations that affect the values of counting semaphores: tx_semaphore_get and tx_semaphore_put. The get operation decreases the semaphore by one. If the semaphore is 0, the get operation fails. The inverse of the get operation is the put operation, which increases the semaphore by one.
Each counting semaphore is a public resource. ThreadX imposes no constraints as to how counting semaphores are used.
An instance of a counting semaphore is a single count. For example, if the count is five, then that semaphore has five instances. Similarly, if the count is zero, then that semaphore has no instances. The get operation takes one instance from the counting semaphore by decrementing its count. Similarly, the put operation places one instance in the counting semaphore by incrementing its count.
Like mutexes, counting semaphores are often used for mutual exclusion. One major difference between these objects is that counting semaphores do not support ownership, a concept that is central to mutexes. Even so, counting semaphores are more versatile; they can also be used for event notification and inter-thread synchronization.
Mutual exclusion pertains to controlling threads access to certain application areas (typically, critical sections and application resources). [43] When used for mutual exclusion, the current count of a semaphore represents the total number of threads that are allowed access to...