Semaphores are used to control access to shared resources or or to communicate between tasks in a multithreaded system or with interrupt service routines. Semaphores can be 0 or 1, or they can be counting semaphores that increment and decreement based on calls to Pend() and Post() functions.
More...
#include <nbrtos.h>
Inherits OS_TASK_DLY_OBJ.
|
| OS_SEM (int32_t cnt=0) |
| Create and initialize a semaphore.
|
|
uint8_t | Init (int32_t cnt=0) |
| Initialize the semaphore object count value.
|
|
uint8_t | Post () |
| Posts to the semaphore, increasing it's value by 1.
|
|
uint8_t | Pend (uint32_t timeoutTicks=WAIT_FOREVER) |
| Wait timeout ticks for the value of the semaphore to be non zero.
|
|
uint8_t | PendUntil (uint32_t timeout_time) |
| Wait until the specified timeout time for a task to post to the semaphore.
|
|
uint8_t | Pend (TickTimeout &t) |
| Wait for the specified number of system time ticks for a task to post to the semaphore.
|
|
uint8_t | PendNoWait () |
| Pend on a semaphore with no waiting period.
|
|
uint32_t | Avail () |
| Returns the number of semaphore counts availble.
|
|
Semaphores are used to control access to shared resources or or to communicate between tasks in a multithreaded system or with interrupt service routines. Semaphores can be 0 or 1, or they can be counting semaphores that increment and decreement based on calls to Pend() and Post() functions.
◆ OS_SEM()
OS_SEM::OS_SEM |
( |
int32_t | cnt = 0 | ) |
|
|
inline |
Create and initialize a semaphore.
- Parameters
-
cnt | Starting semaphore count value. If not specified, default is 0. |
- See also
- Init(int32_t cnt = 0)
◆ Avail()
uint32_t OS_SEM::Avail |
( |
| ) |
|
|
inline |
Returns the number of semaphore counts availble.
Difference between the number of counts used and the total count value.
- Returns
- The number of available semaphore counts
- See also
- Pend(), Post()
◆ Init()
uint8_t OS_SEM::Init |
( |
int32_t | cnt = 0 | ) |
|
Initialize the semaphore object count value.
- Warning
- This must be done before using the semaphore.
- Parameters
-
cnt | Starting semaphore count value. If not specified, default is 0. |
- Returns
- OS_NO_ERR on success, otherwise NBRTOS Error Codes
◆ Pend() [1/2]
Wait for the specified number of system time ticks for a task to post to the semaphore.
- Parameters
-
t | The number of TickTiemout ticks to wait. A value of 0 will wait forever. |
- Returns
- OS_NO_ERR on success, otherwise NBRTOS Error Codes
- See also
- PendNoWait(), PendUntil()
◆ Pend() [2/2]
uint8_t OS_SEM::Pend |
( |
uint32_t | timeoutTicks = WAIT_FOREVER | ) |
|
|
inline |
Wait timeout ticks for the value of the semaphore to be non zero.
- Parameters
-
timeoutTicks | Number of system time ticks to wait. If not specified, will wait forever. |
- Returns
- OS_NO_ERR on success, otherwise NBRTOS Error Codes
- See also
- PendNoWait(), PendUntil()
◆ PendNoWait()
uint8_t OS_SEM::PendNoWait |
( |
| ) |
|
◆ PendUntil()
uint8_t OS_SEM::PendUntil |
( |
uint32_t | timeout_time | ) |
|
|
inline |
Wait until the specified timeout time for a task to post to the semaphore.
- Parameters
-
timeout_time | The system TimeTick value to wait until |
- Returns
- OS_NO_ERR on success, otherwise NBRTOS Error Codes
- See also
- PendNoWait(), Pend()
◆ Post()
The documentation for this struct was generated from the following file: