Mutex

RTOS mutex functions. More...

Functions

zos_result_t zn_rtos_mutex_init (zos_mutex_t *mutex)
 Initializes a mutexInitializes a mutex A mutex is different to a semaphore in that a thread that already holds the lock on the mutex can request the lock again (nested) without causing it to be suspended. More...
 
zos_result_t zn_rtos_mutex_lock (zos_mutex_t *mutex)
 Obtains the lock on a mutexAttempts to obtain the lock on a mutex. More...
 
zos_result_t zn_rtos_mutex_trylock (zos_mutex_t *mutex)
 Tests the state of the lock on a mutex. More...
 
zos_result_t zn_rtos_mutex_unlock (zos_mutex_t *mutex)
 Releases the lock on a mutexReleases a currently held lock on a mutex. More...
 
zos_result_t zn_rtos_mutex_deinit (zos_mutex_t *mutex)
 De-initialise a mutexDeletes a mutex created with zn_rtos_mutex_init() More...
 

Detailed Description

RTOS mutex functions.

Function Documentation

zos_result_t zn_rtos_mutex_deinit ( zos_mutex_t *  mutex)

De-initialise a mutexDeletes a mutex created with zn_rtos_mutex_init()

Parameters
mutex: a pointer to the mutex handle
Returns
ZOS_SUCCESS : on success.
ZOS_ERROR : if an error occurred
zos_result_t zn_rtos_mutex_init ( zos_mutex_t *  mutex)

Initializes a mutexInitializes a mutex A mutex is different to a semaphore in that a thread that already holds the lock on the mutex can request the lock again (nested) without causing it to be suspended.

Parameters
mutex: a pointer to the mutex handle to be initialised
Returns
ZOS_SUCCESS : on success.
ZOS_ERROR : if an error occurred
zos_result_t zn_rtos_mutex_lock ( zos_mutex_t *  mutex)

Obtains the lock on a mutexAttempts to obtain the lock on a mutex.

If the lock is already held by another thead, the calling thread will be suspended until the mutex lock is released by the other thread.

Parameters
mutex: a pointer to the mutex handle to be locked
Returns
ZOS_SUCCESS : on success.
ZOS_ERROR : if an error occurred
zos_result_t zn_rtos_mutex_trylock ( zos_mutex_t *  mutex)

Tests the state of the lock on a mutex.

Parameters
mutex: a pointer to the mutex handle to be locked
Returns
ZOS_SUCCESS : on success (unlocked).
ZOS_ERROR : on error or locked.
zos_result_t zn_rtos_mutex_unlock ( zos_mutex_t *  mutex)

Releases the lock on a mutexReleases a currently held lock on a mutex.

If another thread is waiting on the mutex lock, then it will be resumed.

Parameters
mutex: a pointer to the mutex handle to be unlocked
Returns
ZOS_SUCCESS : on success.
ZOS_ERROR : if an error occurred