HALFRED  0.4.0
Functions
OSMutex interface

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.

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)
 

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

Referenced by SLST_Create().

void OSMUTEX_Destroy ( OSMutex  mutex)

Destroys a mutex

Parameters
mutexmutex to destroy

Referenced by SLST_Destroy().

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

Gives the mutex.

Parameters
mutexmutex to give
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