HALFRED  0.4.0
OSRecursiveMutex interface

Detailed Description

An interface to a recursive mutual exclusion semaphore (recursive mutex) mechanism provided by the OS. The implementation of the OSRecursiveMutex depends on the OS used.


OSRecursiveMutex OSRECMUTEX_Create (void)
void OSRECMUTEX_Destroy (OSRecursiveMutex mutex)
bool OSRECMUTEX_IsValid (OSMutex mutex)
void OSRECMUTEX_Give (OSRecursiveMutex mutex)
int OSRECMUTEX_Take (OSRecursiveMutex mutex, OSTime timeout)

Function Documentation

OSRecursiveMutex OSRECMUTEX_Create ( void  )

Creates a new recursive mutex instance. 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 OSRECMUTEX_Take.

a newly created recursive mutex
void OSRECMUTEX_Destroy ( OSRecursiveMutex  mutex)

Destroys a recursive mutex

mutexrecursive mutex to destroy
bool OSRECMUTEX_IsValid ( OSMutex  mutex)

Checks if a recursive mutex handle represents a valid mutex. Can be used to test if OSRECMUTEX_Create produced a valid mutex. Beware, that checking handle of a mutex, that has been destroyed (OSRECMUTEX_Destroy) yields undefined behavior. On some ports such handle may still be reported as valid.

mutexrecursive mutex to check
true if mutex is valid or false if not
void OSRECMUTEX_Give ( OSRecursiveMutex  mutex)

Gives the recursive mutex.

mutexrecursive mutex to give
int OSRECMUTEX_Take ( OSRecursiveMutex  mutex,
OSTime  timeout 

Takes the recursive 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. Since the mutex is recursive, then if the mutex is obtained in a given task, the following calls to this function from within this task will also report successful mutex acquisition.

mutexrecursive mutex to take
timeoutmaximum time spent waiting for the mutex in miliseconds
0 if the mutex was taken !0 if timeout or error occurred