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 |
C API mutex definitions.
#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 |
Mutex attributes.
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 |
Mutex object storage.
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 |
An enumeration with mutex protocols.
Definition at line 832 of file os-c-decls.h.
anonymous enum |
An enumeration with mutex robustness.
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 860 of file os-c-decls.h.
anonymous enum |
An enumeration with mutex types.
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 883 of file os-c-decls.h.
const os_mutex_attr_t * os_mutex_attr_get_recursive | ( | void | ) |
Get a recursive mutex attributes object instance.
Definition at line 1471 of file os-c-wrapper.cpp.
void os_mutex_attr_init | ( | os_mutex_attr_t * | attr | ) |
Initialise the mutex attributes.
[in] | attr | Pointer to mutex attributes object instance. |
Definition at line 1445 of file os-c-wrapper.cpp.
void os_mutex_attr_recursive_init | ( | os_mutex_attr_t * | attr | ) |
Initialise the recursive mutex attributes.
[in] | attr | Pointer to mutex attributes object instance. |
Definition at line 1458 of file os-c-wrapper.cpp.
void os_mutex_construct | ( | os_mutex_t * | mutex, |
const char * | name, | ||
const os_mutex_attr_t * | attr | ||
) |
Construct a statically allocated mutex object instance.
[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 1485 of file os-c-wrapper.cpp.
void os_mutex_delete | ( | os_mutex_t * | mutex | ) |
Destruct the mutex object instance and deallocate it.
[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 1595 of file os-c-wrapper.cpp.
void os_mutex_destruct | ( | os_mutex_t * | mutex | ) |
Destruct the statically allocated mutex object instance.
[in] | mutex | Pointer to mutex object instance storage. |
os_mutex_construct()
or os_mutex_recursive_construct()
.Definition at line 1526 of file os-c-wrapper.cpp.
const char * os_mutex_get_name | ( | os_mutex_t * | mutex | ) |
Get the mutex name.
[in] | mutex | Pointer to mutex object instance. |
Definition at line 1608 of file os-c-wrapper.cpp.
os_thread_t * os_mutex_get_owner | ( | os_mutex_t * | mutex | ) |
Get the thread that owns the mutex.
[in] | mutex | Pointer to mutex object instance. |
NULL
if not owned.Definition at line 1715 of file os-c-wrapper.cpp.
os_thread_prio_t os_mutex_get_prio_ceiling | ( | os_mutex_t * | mutex | ) |
Get the priority ceiling of a mutex.
[in] | mutex | Pointer to mutex object instance. |
Definition at line 1674 of file os-c-wrapper.cpp.
os_mutex_protocol_t os_mutex_get_protocol | ( | os_mutex_t * | mutex | ) |
Get the mutex protocol.
[in] | mutex | Pointer to mutex object instance. |
Definition at line 1741 of file os-c-wrapper.cpp.
os_mutex_robustness_t os_mutex_get_robustness | ( | os_mutex_t * | mutex | ) |
Get the mutex robustness.
[in] | mutex | Pointer to mutex object instance. |
Definition at line 1754 of file os-c-wrapper.cpp.
os_mutex_type_t os_mutex_get_type | ( | os_mutex_t * | mutex | ) |
Get the mutex type.
[in] | mutex | Pointer to mutex object instance. |
Definition at line 1728 of file os-c-wrapper.cpp.
os_result_t os_mutex_lock | ( | os_mutex_t * | mutex | ) |
Lock/acquire the 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 1621 of file os-c-wrapper.cpp.
os_result_t os_mutex_mark_consistent | ( | os_mutex_t * | mutex | ) |
Mark mutex as consistent.
[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 1702 of file os-c-wrapper.cpp.
os_mutex_t * os_mutex_new | ( | const char * | name, |
const os_mutex_attr_t * | attr | ||
) |
Allocate a mutex object instance and construct it.
[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 1546 of file os-c-wrapper.cpp.
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.
[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 1505 of file os-c-wrapper.cpp.
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.
[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 1570 of file os-c-wrapper.cpp.
os_result_t os_mutex_reset | ( | os_mutex_t * | mutex | ) |
Reset the mutex.
[in] | mutex | Pointer to mutex object instance. |
os_ok | The mutex was reset. |
Definition at line 1767 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 | ||
) |
Change the priority ceiling of a mutex.
[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 1687 of file os-c-wrapper.cpp.
os_result_t os_mutex_timed_lock | ( | os_mutex_t * | mutex, |
os_clock_duration_t | timeout | ||
) |
Timed attempt to lock/acquire the mutex.
[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 1647 of file os-c-wrapper.cpp.
os_result_t os_mutex_try_lock | ( | os_mutex_t * | mutex | ) |
Try to lock/acquire the 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 1634 of file os-c-wrapper.cpp.
os_result_t os_mutex_unlock | ( | os_mutex_t * | mutex | ) |
Unlock/release the 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 1661 of file os-c-wrapper.cpp.