...
Typically, two types of semaphores exist: binary semaphores and counting semaphores. As its name implies, a binary semaphore can only take two values: 0 or 1. A counting semaphore allows for values between 0 and 255, 65,535, or 4,294,967,295, depending on whether the semaphore mechanism is implemented using 8, 16, or 32 bits, respectively. For µCμC/OS-III, the maximum value of a semaphore is determined by the data type OS_SEM_CTR
(see os_type.h
), which can be changed as needed. Along with the semaphore’s value, µCμC/OS-III also keeps track of tasks waiting for the semaphore’s availability.
...
There are a number of operations the application is able to perform on semaphores, summarized in Table 13-2the table below. In this chapter, only the three most used functions used most often are discussed: OSSemCreate()
, OSSemPend()
, and OSSemPost()
. Other The other functions are described in Appendix A, “µCµC/OS-III API Reference”Reference. When semaphores are used for sharing resources, every semaphore function must be called from a task and never from an ISR. The same limitation does not apply when using semaphores for signaling, as described later in Chapter 13.
Function Name | Operation |
---|---|
OSSemCreate() | Create a semaphore. |
OSSemDel() | Delete a semaphore. |
OSSemPend() | Wait on a semaphore. |
OSSemPendAbort() | Abort the wait on a semaphore. |
OSSemPost() | Release or signal a semaphore. |
OSSemSet() | Force the semaphore count to a desired value. |
...