C API mutex definitions. More...
Classes | |
| struct | os_mutex_attr_s |
| Mutex attributes. More... | |
| struct | os_mutex_s |
| Mutex object storage. More... | |
Typedefs | |
| typedef struct os_mutex_attr_s | os_mutex_attr_t |
| Mutex attributes. | |
| typedef struct os_mutex_s | os_mutex_t |
| Mutex object storage. | |
Enumerations | |
| enum | { os_mutex_protocol_none = 0 , os_mutex_protocol_inherit = 1 , os_mutex_protocol_protect = 2 , os_mutex_protocol_default = os_mutex_protocol_inherit } |
| An enumeration with mutex protocols. More... | |
| enum | { os_mutex_robustness_stalled = 0 , os_mutex_robustness_robust = 1 , os_mutex_robustness_default = os_mutex_robustness_stalled } |
| An enumeration with mutex robustness. More... | |
| enum | { os_mutex_type_normal = 0 , os_mutex_type_errorcheck = 1 , os_mutex_type_recursive = 2 , os_mutex_type_default = os_mutex_type_normal } |
| An enumeration with mutex types. More... | |
Mutex Attributes Functions | |
| void | os_mutex_attr_init (os_mutex_attr_t *attr) |
| Initialise the mutex attributes. | |
| void | os_mutex_attr_recursive_init (os_mutex_attr_t *attr) |
| Initialise the recursive mutex attributes. | |
| const os_mutex_attr_t * | os_mutex_attr_get_recursive (void) |
| Get a recursive mutex attributes object instance. | |
Mutex Creation Functions | |
| void | os_mutex_construct (os_mutex_t *mutex, const char *name, const os_mutex_attr_t *attr) |
| Construct a statically allocated mutex object instance. | |
| void | os_mutex_recursive_construct (os_mutex_t *mutex, const char *name, const os_mutex_attr_t *attr) |
| Construct a statically allocated recursive mutex object instance. | |
| void | os_mutex_destruct (os_mutex_t *mutex) |
| Destruct the statically allocated mutex object instance. | |
| os_mutex_t * | os_mutex_new (const char *name, const os_mutex_attr_t *attr) |
| Allocate a mutex object instance and construct it. | |
| os_mutex_t * | os_mutex_recursive_new (const char *name, const os_mutex_attr_t *attr) |
| Allocated a recursive mutex object instance and construct it. | |
| void | os_mutex_delete (os_mutex_t *mutex) |
| Destruct the mutex object instance and deallocate it. | |
Compatibility Macros | |
| #define | os_mutex_create os_mutex_construct |
| #define | os_mutex_recursive_create os_mutex_recursive_construct |
| #define | os_mutex_destroy os_mutex_destruct |
| #define os_mutex_create os_mutex_construct |
Definition at line 1459 of file os-c-api.h.
| #define os_mutex_destroy os_mutex_destruct |
Definition at line 1461 of file os-c-api.h.
| #define os_mutex_recursive_create os_mutex_recursive_construct |
Definition at line 1460 of file os-c-api.h.
| typedef struct os_mutex_attr_s os_mutex_attr_t |
Initialise this structure with os_mutex_attr_init() and then set any of the individual members directly.
| typedef struct os_mutex_s os_mutex_t |
This C structure has the same size as the C++ os::rtos::mutex object and must be initialised with os_mutex_create().
Later on a pointer to it can be used both in C and C++ to refer to the mutex object instance.
The members of this structure are hidden and should not be used directly, but only through specific functions.
| anonymous enum |
Definition at line 831 of file os-c-decls.h.
| anonymous enum |
| Enumerator | |
|---|---|
| os_mutex_robustness_stalled | Normal robustness. |
| os_mutex_robustness_robust | Enhanced robustness at thread termination. |
| os_mutex_robustness_default | Default mutex robustness. |
Definition at line 859 of file os-c-decls.h.
| anonymous enum |
| Enumerator | |
|---|---|
| os_mutex_type_normal | Normal mutex behaviour. |
| os_mutex_type_errorcheck | Check mutex behaviour. |
| os_mutex_type_recursive | Recursive mutex behaviour. |
| os_mutex_type_default | Default mutex type. |
Definition at line 882 of file os-c-decls.h.
| const os_mutex_attr_t * os_mutex_attr_get_recursive | ( | void | ) |
Definition at line 1649 of file os-c-wrapper.cpp.
References os::rtos::mutex::initializer_recursive.
| void os_mutex_attr_init | ( | os_mutex_attr_t * | attr | ) |
| [in] | attr | Pointer to mutex attributes object instance. |
Definition at line 1623 of file os-c-wrapper.cpp.
| void os_mutex_attr_recursive_init | ( | os_mutex_attr_t * | attr | ) |
| [in] | attr | Pointer to mutex attributes object instance. |
Definition at line 1636 of file os-c-wrapper.cpp.
| void os_mutex_construct | ( | os_mutex_t * | mutex, |
| const char * | name, | ||
| const os_mutex_attr_t * | attr | ||
| ) |
| [in] | mutex | Pointer to mutex object instance storage. |
| [in] | name | Pointer to name (may be NULL). |
| [in] | attr | Pointer to attributes (may be NULL). |
os_mutex_destruct().Definition at line 1663 of file os-c-wrapper.cpp.
References os::rtos::mutex::initializer_normal.
| void os_mutex_delete | ( | os_mutex_t * | mutex | ) |
| [in] | mutex | Pointer to dynamically allocated mutex object instance. |
Destruct the mutex and deallocate the dynamically allocated space using the RTOS system allocator.
delete ptr_mutex. os_mutex_new() or os_mutex_recursive_new().Definition at line 1773 of file os-c-wrapper.cpp.
| void os_mutex_destruct | ( | os_mutex_t * | mutex | ) |
| [in] | mutex | Pointer to mutex object instance storage. |
os_mutex_construct() or os_mutex_recursive_construct().Definition at line 1704 of file os-c-wrapper.cpp.
| const char * os_mutex_get_name | ( | os_mutex_t * | mutex | ) |
| [in] | mutex | Pointer to mutex object instance. |
Definition at line 1786 of file os-c-wrapper.cpp.
| os_thread_t * os_mutex_get_owner | ( | os_mutex_t * | mutex | ) |
| [in] | mutex | Pointer to mutex object instance. |
NULL if not owned.Definition at line 1895 of file os-c-wrapper.cpp.
| os_thread_prio_t os_mutex_get_prio_ceiling | ( | os_mutex_t * | mutex | ) |
| [in] | mutex | Pointer to mutex object instance. |
Definition at line 1852 of file os-c-wrapper.cpp.
| os_mutex_protocol_t os_mutex_get_protocol | ( | os_mutex_t * | mutex | ) |
| [in] | mutex | Pointer to mutex object instance. |
Definition at line 1921 of file os-c-wrapper.cpp.
| os_mutex_robustness_t os_mutex_get_robustness | ( | os_mutex_t * | mutex | ) |
| [in] | mutex | Pointer to mutex object instance. |
Definition at line 1934 of file os-c-wrapper.cpp.
| os_mutex_type_t os_mutex_get_type | ( | os_mutex_t * | mutex | ) |
| [in] | mutex | Pointer to mutex object instance. |
Definition at line 1908 of file os-c-wrapper.cpp.
| os_result_t os_mutex_lock | ( | os_mutex_t * | mutex | ) |
| [in] | mutex | Pointer to mutex object instance. |
| os_ok | The mutex was locked. |
| EPERM | Cannot be invoked from an Interrupt Service Routines. |
| ENOTRECOVERABLE | The state protected by the mutex is not recoverable.. |
| EAGAIN | The mutex could not be acquired because the maximum number of recursive locks for mutex has been exceeded. |
| EINVAL | The mutex was created with the protocol attribute having the value os_mutex_protocol_protect and the calling thread's priority is higher than the mutex's current priority ceiling. |
| EOWNERDEAD | The mutex is a robust mutex and the process containing the previous owning thread terminated while holding the mutex lock. The mutex lock shall be acquired by the calling thread and it is up to the new owner to make the state consistent. |
| EDEADLK | The mutex type is os_mutex_type_errorcheck and the current thread already owns the mutex. |
Definition at line 1799 of file os-c-wrapper.cpp.
| os_result_t os_mutex_mark_consistent | ( | os_mutex_t * | mutex | ) |
| [in] | mutex | Pointer to mutex object instance. |
| os_ok | The mutex was marked as consistent. |
| EPERM | Cannot be invoked from an Interrupt Service Routines. |
| EINVAL | The mutex object referenced by mutex is not robust or does not protect an inconsistent state. |
Definition at line 1882 of file os-c-wrapper.cpp.
| os_mutex_t * os_mutex_new | ( | const char * | name, |
| const os_mutex_attr_t * | attr | ||
| ) |
| [in] | name | Pointer to name (may be NULL). |
| [in] | attr | Pointer to attributes (may be NULL). |
Dynamically allocate the mutex object instance using the RTOS system allocator and construct it.
new mutex(...). os_mutex_delete().Definition at line 1724 of file os-c-wrapper.cpp.
References os::rtos::mutex::initializer_normal.
| void os_mutex_recursive_construct | ( | os_mutex_t * | mutex, |
| const char * | name, | ||
| const os_mutex_attr_t * | attr | ||
| ) |
| [in] | mutex | Pointer to mutex object instance storage. |
| [in] | name | Pointer to name (may be NULL). |
| [in] | attr | Pointer to attributes (may be NULL). |
os_mutex_destruct().Definition at line 1683 of file os-c-wrapper.cpp.
References os::rtos::mutex::initializer_recursive.
| os_mutex_t * os_mutex_recursive_new | ( | const char * | name, |
| const os_mutex_attr_t * | attr | ||
| ) |
| [in] | name | Pointer to name (may be NULL). |
| [in] | attr | Pointer to attributes (may be NULL). |
Dynamically allocate the recursive mutex object instance using the RTOS system allocator and construct it.
new mutex_recursive(...). os_mutex_delete().Definition at line 1748 of file os-c-wrapper.cpp.
References os::rtos::mutex::initializer_recursive.
| os_result_t os_mutex_reset | ( | os_mutex_t * | mutex | ) |
| [in] | mutex | Pointer to mutex object instance. |
| os_ok | The mutex was reset. |
Definition at line 1947 of file os-c-wrapper.cpp.
| os_result_t os_mutex_set_prio_ceiling | ( | os_mutex_t * | mutex, |
| os_thread_prio_t | prio_ceiling, | ||
| os_thread_prio_t * | old_prio_ceiling | ||
| ) |
| [in] | mutex | Pointer to mutex object instance. |
| [in] | prio_ceiling | new priority. |
| [out] | old_prio_ceiling | pointer to location where to store the previous priority; may be NULL. |
| os_ok | The priority was changed. |
| EPERM | Cannot be invoked from an Interrupt Service Routines. |
Definition at line 1867 of file os-c-wrapper.cpp.
| os_result_t os_mutex_timed_lock | ( | os_mutex_t * | mutex, |
| os_clock_duration_t | timeout | ||
| ) |
| [in] | mutex | Pointer to mutex object instance. |
| [in] | timeout | Timeout to wait, in clock units (ticks or seconds). |
| os_ok | The mutex was locked. |
| EPERM | Cannot be invoked from an Interrupt Service Routines. |
| ETIMEDOUT | The mutex could not be locked before the specified timeout expired. |
| ENOTRECOVERABLE | The state protected by the mutex is not recoverable. |
| EAGAIN | The mutex could not be acquired because the maximum number of recursive locks for mutex has been exceeded. |
| EDEADLK | The mutex type is os_mutex_type_errorcheck and the current thread already owns the mutex. |
| EINVAL | The process or thread would have blocked, and the timeout parameter is invalid. |
| EOWNERDEAD | The mutex is a robust mutex and the process containing the previous owning thread terminated while holding the mutex lock. The mutex lock shall be acquired by the calling thread and it is up to the new owner to make the state consistent. |
Definition at line 1825 of file os-c-wrapper.cpp.
| os_result_t os_mutex_try_lock | ( | os_mutex_t * | mutex | ) |
| [in] | mutex | Pointer to mutex object instance. |
| os_ok | The mutex was locked. |
| EPERM | Cannot be invoked from an Interrupt Service Routines. |
| ENOTRECOVERABLE | The state protected by the mutex is not recoverable.. |
| EAGAIN | The mutex could not be acquired because the maximum number of recursive locks for mutex has been exceeded. |
| EINVAL | The mutex was created with the protocol attribute having the value os_mutex_protocol_protect and the calling thread's priority is higher than the mutex's current priority ceiling. |
| EOWNERDEAD | The mutex is a robust mutex and the process containing the previous owning thread terminated while holding the mutex lock. The mutex lock shall be acquired by the calling thread and it is up to the new owner to make the state consistent. |
| EDEADLK | The mutex type is os_mutex_type_errorcheck and the current thread already owns the mutex. |
| EWOULDBLOCK | The mutex could not be acquired because it was already locked. |
Definition at line 1812 of file os-c-wrapper.cpp.
| os_result_t os_mutex_unlock | ( | os_mutex_t * | mutex | ) |
| [in] | mutex | Pointer to mutex object instance. |
| os_ok | The mutex was unlocked. |
| EPERM | Cannot be invoked from an Interrupt Service Routine; the mutex type is os_mutex_type_errorcheck or os_mutex_type_recursive, or the mutex is a robust mutex, and the current thread does not own the mutex. |
| ENOTRECOVERABLE | The mutex was not unlocked. |
Definition at line 1839 of file os-c-wrapper.cpp.