An interface to a mutual exclusion semaphore (mutex) mechanism provided by the OS. The implementation of the OSMutex depends on the OS used, however the mutex is guaranteed to be non-recursive.
OSMutex OSMUTEX_Create |
( |
void |
| ) |
|
Creates a new mutex instance. This mutex is non-recursive. The mutex implementation depends on the actual OS. A newly created mutex has no owner, it is available to be taken through a call to OSMUTEX_Take.
- Returns
- a newly created mutex
Referenced by SLST_Create().
void OSMUTEX_Destroy |
( |
OSMutex |
mutex | ) |
|
bool OSMUTEX_IsValid |
( |
OSMutex |
mutex | ) |
|
Checks if a mutex handle represents a valid mutex. Can be used to test if OSMUTEX_Create produced a valid mutex. Beware, that checking handle of a mutex, that has been destroyed (OSMUTEX_Destroy) yields undefined behavior. On some ports such handle may still be reported as valid.
- Parameters
-
- Returns
- true if mutex is valid or false if not
void OSMUTEX_Give |
( |
OSMutex |
mutex | ) |
|
Gives the mutex.
- Parameters
-
int OSMUTEX_Take |
( |
OSMutex |
mutex, |
|
|
OSTime |
timeout |
|
) |
| |
Takes the mutex. If the mutex is not immediately available, the task from which the call was made is blocked. The maximum time spent waiting for the mutex is specified by the timeout parameter.
- Parameters
-
mutex | mutex to take |
timeout | maximum time spent waiting for the mutex in miliseconds |
- Returns
- 0 if the mutex was taken !0 if timeout or error occurred