Lightweight inverse semaphore implementation.
More...
Lightweight inverse semaphore implementation.
◆ sema_inv_init()
static void sema_inv_init |
( |
sema_inv_t * |
s, |
|
|
uint32_t |
value |
|
) |
| |
|
inlinestatic |
Initialize an inverse semaphore.
- Parameters
-
s | an inverse semaphore |
value | start value, either a counter or a bit mask |
Definition at line 99 of file sema_inv.h.
◆ sema_inv_post()
Signal semaphore (counter mode).
Decrements the semaphore counter by one.
If the counter reaches zero, the waiting thread is woken.
- Parameters
-
- Return values
-
`true` | the value of the semaphore has reached zero and the waiting thread has been woken |
`false` | the semaphore has not reached zero yet |
◆ sema_inv_post_mask()
bool sema_inv_post_mask |
( |
sema_inv_t * |
s, |
|
|
uint32_t |
mask |
|
) |
| |
Signal semaphore (mask mode).
Clears the bits specified by @p mask from the semaphore value.
If the value reaches zero, the waiting thread is woken.
- Parameters
-
s | an inverse semaphore |
mask | bit mask to clear from the semaphore value |
- Return values
-
`true` | the value of the semaphore has reached zero and the waiting thread has been woken |
`false` | the semaphore has not reached zero yet |
◆ sema_inv_try_wait()
Check if the inverse semaphore value has reached zero.
- Parameters
-
- Returns
- 1 if the semaphore value has reached zero 0 otherwise
Definition at line 124 of file sema_inv.h.
◆ sema_inv_wait()
Wait for the inverse semaphore value to reach zero.
- Parameters
-
Definition at line 111 of file sema_inv.h.
◆ sema_inv_wait_timeout()
static int sema_inv_wait_timeout |
( |
sema_inv_t * |
s, |
|
|
uint32_t |
us |
|
) |
| |
|
inlinestatic |
Wait for the inverse semaphore value to reach zero or a timeout being reached.
- Parameters
-
s | An inverse semaphore. |
us | Time in microseconds until the semaphore times out. |
- Returns
- 0 if the semaphore value has reached zero -1 when the timeout occurred
Definition at line 140 of file sema_inv.h.