Provides counting semaphore support for task synchronization.
◆ mmosal_sem_create()
| struct mmosal_sem * mmosal_sem_create |
( |
unsigned |
max_count, |
|
|
unsigned |
initial_count, |
|
|
const char * |
name |
|
) |
| |
Create a new counting semaphore.
- Parameters
-
| max_count | The maximum count (i.e., number of times the semaphore can be given). |
| initial_count | The initial count (i.e., number of times the semaphore is implicitly given when it is created). |
| name | The name of the semaphore. |
- Returns
- an opaque handle to the semaphore, or
NULL on failure.
◆ mmosal_sem_delete()
| void mmosal_sem_delete |
( |
struct mmosal_sem * |
sem | ) |
|
Delete the given counting semaphore.
- Parameters
-
◆ mmosal_sem_get_count()
| uint32_t mmosal_sem_get_count |
( |
struct mmosal_sem * |
sem | ) |
|
Returns the current count of the semaphore.
- Parameters
-
| sem | The semaphore being queried. |
- Returns
- The count of the semaphore being queried.
◆ mmosal_sem_give()
| bool mmosal_sem_give |
( |
struct mmosal_sem * |
sem | ) |
|
Give a counting semaphore.
- Warning
- May not be invoked from an ISR.
- Parameters
-
| sem | The semaphore to give. |
- Returns
true on success, else false.
◆ mmosal_sem_give_from_isr()
| bool mmosal_sem_give_from_isr |
( |
struct mmosal_sem * |
sem | ) |
|
Give a counting semaphore (from ISR context).
- Warning
- May only be invoked from an ISR.
- Parameters
-
| sem | The semaphore to give. |
- Returns
true on success, else false.
◆ mmosal_sem_wait()
| bool mmosal_sem_wait |
( |
struct mmosal_sem * |
sem, |
|
|
uint32_t |
timeout_ms |
|
) |
| |
Wait for a counting semaphore.
- Parameters
-
| sem | The semaphore to wait for. |
| timeout_ms | Timeout after which to give up waiting (in milliseconds). |
- Returns
true if the the semaphore was taken successfully, else false.