Docs

You are here:
OSMutex interface

Functions

OSMutex OSMUTEX_Create (void)
 
void OSMUTEX_Destroy (OSMutex mutex)
 
bool OSMUTEX_IsValid (OSMutex mutex)
 
void OSMUTEX_Give (OSMutex mutex)
 
int OSMUTEX_Take (OSMutex mutex, OSTime timeout)
 

Detailed Description

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.

Function Documentation

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
void OSMUTEX_Destroy ( OSMutex  mutex)

Destroys a mutex

Parameters
mutexmutex to destroy
void OSMUTEX_Give ( OSMutex  mutex)

Gives the mutex.

Parameters
mutexmutex to give
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
mutexmutex to check
Returns
true if mutex is valid or false if not
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
mutexmutex to take
timeoutmaximum time spent waiting for the mutex in miliseconds
Returns
0 if the mutex was taken !0 if timeout or error occurred
Go to Top