lwpa
0.1.0
LightWeight Platform Abstraction (lwpa)
|
View other versions:
|
A mutual-exclusion (mutex) object.
Sometimes also referred to as a critical section. Only one thread can take the mutex at a time using lwpa_mutex_take(). Where possible on real-time platforms, the mutex provides priority inheritance.
lwpa_mutex implementations use the following constructs under the hood on various platforms:
Windows | Critical Section objects FreeRTOS/lwIP | Mutexes MQX | Lightweight Semaphores
Typedefs | |
typedef UNDEFINED | lwpa_mutex_t |
The mutex identifier. More... | |
Functions | |
bool | lwpa_mutex_create (lwpa_mutex_t *id) |
Create a new mutex. More... | |
bool | lwpa_mutex_take (lwpa_mutex_t *id, int wait_ms) |
Acquire a mutex. More... | |
void | lwpa_mutex_give (lwpa_mutex_t *id) |
Release a mutex. More... | |
void | lwpa_mutex_destroy (lwpa_mutex_t *id) |
Destroy a mutex object. More... | |
typedef UNDEFINED lwpa_mutex_t |
The mutex identifier.
Depending on the platform, this could be a scalar type or a struct.
bool lwpa_mutex_create | ( | lwpa_mutex_t * | id | ) |
Create a new mutex.
[in,out] | id | Mutex identifier on which to create a mutex. If this function returns true, id becomes valid for calls to lwpa_mutex_take() and lwpa_mutex_give(). |
void lwpa_mutex_destroy | ( | lwpa_mutex_t * | id | ) |
Destroy a mutex object.
[in] | id | Identifier for the mutex to destroy. |
void lwpa_mutex_give | ( | lwpa_mutex_t * | id | ) |
Release a mutex.
[in] | id | Identifier for the mutex to release. |
bool lwpa_mutex_take | ( | lwpa_mutex_t * | id, |
int | wait_ms | ||
) |
Acquire a mutex.
[in] | id | Identifier for the mutex to acquire. |
[in] | wait_ms | How long to wait to acquire the mutex, in milliseconds (use LWPA_WAIT_FOREVER to wait indefinitely). |