APIs for acquiring and working with Mutexes.
Create a recursive mutex.
Creates a binary mutex which can be used to synchronize between threads and between threads and ISRs. Created mutexes are recursive and support priority inheritance.
This function has been replaced by cy_rtos_init_mutex2 which allow for specifying whether or not the mutex supports recursion or not.
cy_rtos_init_mutex2(cy_mutex_t *mutex, bool recursive)¶
Create a mutex which can support recursion or not.
Creates a binary mutex which can be used to synchronize between threads and between threads and ISRs. Created mutexes can support priority inheritance if recursive.
Not all RTOS implementations support non-recursive mutexes. In this case a recursive mutex will be created.
cy_rtos_get_mutex(cy_mutex_t *mutex, cy_time_t timeout_ms)¶
Get a mutex.
If the mutex is available, it is acquired and this function returned. If the mutex is not available, the thread waits until the mutex is available or until the timeout occurs.
This function must not be called from an interrupt context as it may block.
[in] mutex: Pointer to the mutex handle
[in] timeout_ms: Maximum number of milliseconds to wait while attempting to get the mutex. Use the CY_RTOS_NEVER_TIMEOUT constant to wait forever. Must be zero if in_isr is true.
Set a mutex.
The mutex is released allowing any other threads waiting on the mutex to obtain the semaphore.