Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: TYBLE16_simple_data_logger TYBLE16_MP3_Air
Mutex class
[RTOS]
Data Structures | |
class | Mutex |
The Mutex class is used to synchronize the execution of threads. More... | |
Functions | |
Mutex () | |
Create and Initialize a Mutex object. | |
Mutex (const char *name) | |
Create and Initialize a Mutex object. | |
~Mutex () | |
Mutex destructor. | |
osStatus | lock () |
Wait until a Mutex becomes available. | |
bool | trylock () |
Try to lock the mutex, and return immediately. | |
bool | trylock_for (uint32_t millisec) |
Try to lock the mutex for a specified time. | |
bool | trylock_until (uint64_t millisec) |
Try to lock the mutex until specified time. | |
osStatus | unlock () |
Unlock the mutex that has previously been locked by the same thread. |
Function Documentation
osStatus lock | ( | void | ) | [inherited] |
Wait until a Mutex becomes available.
- Returns:
- status code that indicates the execution status of the function: osOK the mutex has been obtained.
- Note:
- You cannot call this function from ISR context.
- This function treats RTOS errors as fatal system errors, so it can only return osOK. Use of the return value is deprecated, as the return is expected to become void in the future.
Mutex | ( | ) | [inherited] |
Mutex | ( | const char * | name ) | [inherited] |
bool trylock | ( | ) | [inherited] |
bool trylock_for | ( | uint32_t | millisec ) | [inherited] |
Try to lock the mutex for a specified time.
- Parameters:
-
millisec timeout value.
- Returns:
- true if the mutex was acquired, false otherwise.
- Note:
- the underlying RTOS may have a limit to the maximum wait time due to internal 32-bit computations, but this is guaranteed to work if the wait is <= 0x7fffffff milliseconds (~24 days). If the limit is exceeded, the lock attempt will time out earlier than specified.
- You cannot call this function from ISR context.
bool trylock_until | ( | uint64_t | millisec ) | [inherited] |
Try to lock the mutex until specified time.
- Parameters:
-
millisec absolute timeout time, referenced to Kernel::get_ms_count()
- Returns:
- true if the mutex was acquired, false otherwise.
- Note:
- the underlying RTOS may have a limit to the maximum wait time due to internal 32-bit computations, but this is guaranteed to work if the wait is <= 0x7fffffff milliseconds (~24 days). If the limit is exceeded, the lock attempt will time out earlier than specified.
- You cannot call this function from ISR context.
osStatus unlock | ( | void | ) | [inherited] |
Unlock the mutex that has previously been locked by the same thread.
- Returns:
- status code that indicates the execution status of the function: osOK the mutex has been released.
- Note:
- You cannot call this function from ISR context.
- This function treats RTOS errors as fatal system errors, so it can only return osOK. Use of the return value is deprecated, as the return is expected to become void in the future.
Generated on Tue Jul 12 2022 13:55:26 by
