Mutex¶
-
group
group_abstraction_rtos_mutex
APIs for acquiring and working with Mutexes.
Unnamed Group
-
cy_rtos_init_mutex
(mutex)¶ 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.
- Parameters
mutex – [out] Pointer to the mutex handle to be initialized
- Returns
The status of mutex creation request. [CY_RSLT_SUCCESS, CY_RTOS_NO_MEMORY, CY_RTOS_GENERAL_ERROR]
-
cy_rslt_t
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.
note
Not all RTOS implementations support non-recursive mutexes. In this case a recursive mutex will be created.
- Parameters
mutex – [out] Pointer to the mutex handle to be initialized
recursive – [in] Should the created mutex support recursion or not
- Returns
The status of mutex creation request. [CY_RSLT_SUCCESS, CY_RTOS_NO_MEMORY, CY_RTOS_GENERAL_ERROR]
-
cy_rslt_t
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.
note
This function must not be called from an interrupt context as it may block.
- Parameters
mutex – [in] Pointer to the mutex handle
timeout_ms – [in] 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.
- Returns
The status of the get mutex. Returns timeout if mutex was not acquired before timeout_ms period. [CY_RSLT_SUCCESS, CY_RTOS_TIMEOUT, CY_RTOS_GENERAL_ERROR]
-
cy_rslt_t
cy_rtos_set_mutex
(cy_mutex_t *mutex)¶ Set a mutex.
The mutex is released allowing any other threads waiting on the mutex to obtain the semaphore.
- Parameters
mutex – [in] Pointer to the mutex handle
- Returns
The status of the set mutex request. [CY_RSLT_SUCCESS, CY_RTOS_GENERAL_ERROR]
-
cy_rslt_t
cy_rtos_deinit_mutex
(cy_mutex_t *mutex)¶ Deletes a mutex.
This function frees the resources associated with a sempahore.
- Parameters
mutex – [in] Pointer to the mutex handle
- Returns
The status to the delete request. [CY_RSLT_SUCCESS, CY_RTOS_GENERAL_ERROR]
-