µOS++ IIIe Reference 7.0.0
The third edition of µOS++, a POSIX inspired open source framework, written in C++
Loading...
Searching...
No Matches

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_tos_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_tos_mutex_new (const char *name, const os_mutex_attr_t *attr)
 Allocate a mutex object instance and construct it.
 
os_mutex_tos_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.
 

Mutex Functions

const char * os_mutex_get_name (os_mutex_t *mutex)
 Get the mutex name.
 
os_result_t os_mutex_lock (os_mutex_t *mutex)
 Lock/acquire the mutex.
 
os_result_t os_mutex_try_lock (os_mutex_t *mutex)
 Try to lock/acquire the mutex.
 
os_result_t os_mutex_timed_lock (os_mutex_t *mutex, os_clock_duration_t timeout)
 Timed attempt to lock/acquire the mutex.
 
os_result_t os_mutex_unlock (os_mutex_t *mutex)
 Unlock/release the mutex.
 
os_thread_prio_t os_mutex_get_prio_ceiling (os_mutex_t *mutex)
 Get the priority ceiling of a mutex.
 
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.
 
os_result_t os_mutex_mark_consistent (os_mutex_t *mutex)
 Mark mutex as consistent.
 
os_thread_tos_mutex_get_owner (os_mutex_t *mutex)
 Get the thread that owns the mutex.
 
os_mutex_type_t os_mutex_get_type (os_mutex_t *mutex)
 Get the mutex type.
 
os_mutex_protocol_t os_mutex_get_protocol (os_mutex_t *mutex)
 Get the mutex protocol.
 
os_mutex_robustness_t os_mutex_get_robustness (os_mutex_t *mutex)
 Get the mutex robustness.
 
os_result_t os_mutex_reset (os_mutex_t *mutex)
 Reset the mutex.
 

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
 

Detailed Description

For the complete definition, see
RTOS C++ API
Examples
int
os_main (int argc, char* argv[])
{
{
os_mutex_construct (&mx1, "mx1", NULL);
os_mutex_lock (&mx1);
name = os_mutex_get_name (&mx1);
assert(strcmp (name, "mx1") == 0);
os_mutex_set_prio_ceiling (&mx1, prio, NULL);
th = os_mutex_get_owner (&mx1);
if (th != NULL)
{
}
}
{
// Custom mutex, with RTC.
amx2.mx_max_count = 7;
os_mutex_construct (&mx2, "mx2", &amx2);
}
{
// Recursive mutex.
}
{
// Custom recursive mutex, with RTC.
os_mutex_attr_init_recursive (&amx4);
os_mutex_construct (&mx4, "mx4", &amx4);
}
}
os_clock_t * os_clock_get_rtclock(void)
Get rtclock (the real-time clock).
const char * os_mutex_get_name(os_mutex_t *mutex)
Get the mutex name.
os_thread_prio_t os_mutex_get_prio_ceiling(os_mutex_t *mutex)
Get the priority ceiling of a mutex.
void os_mutex_destruct(os_mutex_t *mutex)
Destruct the statically allocated mutex object instance.
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.
void os_mutex_attr_init(os_mutex_attr_t *attr)
Initialise the mutex attributes.
os_result_t os_mutex_timed_lock(os_mutex_t *mutex, os_clock_duration_t timeout)
Timed attempt to lock/acquire the mutex.
os_result_t os_mutex_try_lock(os_mutex_t *mutex)
Try to lock/acquire the mutex.
os_result_t os_mutex_unlock(os_mutex_t *mutex)
Unlock/release the mutex.
os_thread_t * os_mutex_get_owner(os_mutex_t *mutex)
Get the thread that owns the mutex.
os_result_t os_mutex_lock(os_mutex_t *mutex)
Lock/acquire the mutex.
os_result_t os_mutex_reset(os_mutex_t *mutex)
Reset the mutex.
const os_mutex_attr_t * os_mutex_attr_get_recursive(void)
Get a recursive mutex attributes object instance.
void os_mutex_construct(os_mutex_t *mutex, const char *name, const os_mutex_attr_t *attr)
Construct a statically allocated mutex object instance.
@ os_mutex_protocol_protect
Execute at the highest priority.
Definition os-c-decls.h:846
@ os_mutex_type_recursive
Recursive mutex behaviour.
Definition os-c-decls.h:897
@ os_mutex_robustness_stalled
Normal robustness.
Definition os-c-decls.h:864
const char * os_thread_get_name(os_thread_t *thread)
Get the thread name.
uint8_t os_thread_prio_t
Type of variables holding thread priorities.
Definition os-c-decls.h:362
@ os_thread_priority_high
Definition os-c-decls.h:277
int os_main(int argc, char *argv[])
Application entry point, running on the main thread context.
Mutex attributes.
Definition os-c-decls.h:923
os_mutex_type_t mx_type
Mutex type.
Definition os-c-decls.h:947
os_mutex_protocol_t mx_protocol
Mutex protocol.
Definition os-c-decls.h:937
os_mutex_count_t mx_max_count
Recursive mutex max count.
Definition os-c-decls.h:952
os_mutex_robustness_t mx_robustness
Mutex robustness.
Definition os-c-decls.h:942
os_thread_prio_t mx_priority_ceiling
Mutex priority ceiling.
Definition os-c-decls.h:932
void * clock
Pointer to clock object instance.
Definition os-c-decls.h:927
Mutex object storage.
Definition os-c-decls.h:973
Thread object storage.
Definition os-c-decls.h:563

Macro Definition Documentation

◆ os_mutex_create

#define os_mutex_create   os_mutex_construct

Definition at line 1459 of file os-c-api.h.

◆ os_mutex_destroy

#define os_mutex_destroy   os_mutex_destruct

Definition at line 1461 of file os-c-api.h.

◆ os_mutex_recursive_create

#define os_mutex_recursive_create   os_mutex_recursive_construct

Definition at line 1460 of file os-c-api.h.

Typedef Documentation

◆ os_mutex_attr_t

Initialise this structure with os_mutex_attr_init() and then set any of the individual members directly.

See also
os::rtos::mutex::attributes

◆ os_mutex_t

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.

See also
os::rtos::mutex

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
See also
os::rtos::mutex::protocol
Enumerator
os_mutex_protocol_none 

Priority and scheduling not affected by mutex ownership.

os_mutex_protocol_inherit 

Inherit priority from highest priority thread.

os_mutex_protocol_protect 

Execute at the highest priority.

os_mutex_protocol_default 

Default mutex protocol.

Definition at line 831 of file os-c-decls.h.

832 {
837
842
847
852 };
@ os_mutex_protocol_inherit
Inherit priority from highest priority thread.
Definition os-c-decls.h:841
@ os_mutex_protocol_none
Priority and scheduling not affected by mutex ownership.
Definition os-c-decls.h:836
@ os_mutex_protocol_default
Default mutex protocol.
Definition os-c-decls.h:851

◆ anonymous enum

anonymous enum
See also
os::rtos::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 859 of file os-c-decls.h.

860 {
865
870
875 };
@ os_mutex_robustness_default
Default mutex robustness.
Definition os-c-decls.h:874
@ os_mutex_robustness_robust
Enhanced robustness at thread termination.
Definition os-c-decls.h:869

◆ anonymous enum

anonymous enum
See also
os::rtos::mutex::type
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.

883 {
888
893
898
903 };
@ os_mutex_type_errorcheck
Check mutex behaviour.
Definition os-c-decls.h:892
@ os_mutex_type_default
Default mutex type.
Definition os-c-decls.h:902
@ os_mutex_type_normal
Normal mutex behaviour.
Definition os-c-decls.h:887

Function Documentation

◆ os_mutex_attr_get_recursive()

const os_mutex_attr_t * os_mutex_attr_get_recursive ( void  )
Returns
Pointer to mutex attributes object instance.
Note
Can be invoked from Interrupt Service Routines.
For the complete definition, see
os::rtos::mutex::initializer_recursive

Definition at line 1649 of file os-c-wrapper.cpp.

1650{
1652}
static const attributes_recursive initializer_recursive
Default recursive mutex initialiser.
Definition os-mutex.h:341

References os::rtos::mutex::initializer_recursive.

◆ os_mutex_attr_init()

void os_mutex_attr_init ( os_mutex_attr_t attr)
Parameters
[in]attrPointer to mutex attributes object instance.
Returns
Nothing.
Warning
Cannot be invoked from Interrupt Service Routines.
For the complete definition, see
os::rtos::mutex::attributes

Definition at line 1623 of file os-c-wrapper.cpp.

1624{
1625 assert (attr != nullptr);
1626 new (attr) mutex::attributes ();
1627}
Mutex attributes.
Definition os-mutex.h:202

◆ os_mutex_attr_recursive_init()

void os_mutex_attr_recursive_init ( os_mutex_attr_t attr)
Parameters
[in]attrPointer to mutex attributes object instance.
Returns
Nothing.
Warning
Cannot be invoked from Interrupt Service Routines.
For the complete definition, see
os::rtos::mutex::attributes_recursive

Definition at line 1636 of file os-c-wrapper.cpp.

1637{
1638 assert (attr != nullptr);
1639 new (attr) mutex::attributes_recursive ();
1640}
Recursive mutex attributes.
Definition os-mutex.h:302

◆ os_mutex_construct()

void os_mutex_construct ( os_mutex_t mutex,
const char *  name,
const os_mutex_attr_t attr 
)
Parameters
[in]mutexPointer to mutex object instance storage.
[in]namePointer to name (may be NULL).
[in]attrPointer to attributes (may be NULL).
Returns
Nothing.
Note
Must be paired with os_mutex_destruct().
Warning
Cannot be invoked from Interrupt Service Routines.
For the complete definition, see
os::rtos::mutex

Definition at line 1663 of file os-c-wrapper.cpp.

1665{
1666 assert (mutex != nullptr);
1667 if (attr == nullptr)
1668 {
1670 }
1671 new (mutex) rtos::mutex (name, (const mutex::attributes&)*attr);
1672}
POSIX compliant mutex.
Definition os-mutex.h:52
static const attributes initializer_normal
Default normal mutex initialiser.
Definition os-mutex.h:292

References os::rtos::mutex::initializer_normal.

◆ os_mutex_delete()

void os_mutex_delete ( os_mutex_t mutex)
Parameters
[in]mutexPointer to dynamically allocated mutex object instance.
Returns
Nothing.

Destruct the mutex and deallocate the dynamically allocated space using the RTOS system allocator.

Note
Equivalent of C++ delete ptr_mutex.
Must be paired with os_mutex_new() or os_mutex_recursive_new().
Warning
Cannot be invoked from Interrupt Service Routines.
For the complete definition, see
os::rtos::mutex

Definition at line 1773 of file os-c-wrapper.cpp.

1774{
1775 assert (mutex != nullptr);
1776 delete reinterpret_cast<rtos::mutex*> (mutex);
1777}

◆ os_mutex_destruct()

void os_mutex_destruct ( os_mutex_t mutex)
Parameters
[in]mutexPointer to mutex object instance storage.
Returns
Nothing.
Note
Must be paired with os_mutex_construct() or os_mutex_recursive_construct().
Warning
Cannot be invoked from Interrupt Service Routines.
For the complete definition, see
os::rtos::mutex

Definition at line 1704 of file os-c-wrapper.cpp.

1705{
1706 assert (mutex != nullptr);
1707 (reinterpret_cast<rtos::mutex&> (*mutex)).~mutex ();
1708}

◆ os_mutex_get_name()

const char * os_mutex_get_name ( os_mutex_t mutex)
Parameters
[in]mutexPointer to mutex object instance.
Returns
Null terminated string.
Note
Can be invoked from Interrupt Service Routines.
For the complete definition, see
os::rtos::mutex::name()

Definition at line 1786 of file os-c-wrapper.cpp.

1787{
1788 assert (mutex != nullptr);
1789 return (reinterpret_cast<rtos::mutex&> (*mutex)).name ();
1790}

◆ os_mutex_get_owner()

os_thread_t * os_mutex_get_owner ( os_mutex_t mutex)
Parameters
[in]mutexPointer to mutex object instance.
Returns
Pointer to thread or NULL if not owned.
Warning
Cannot be invoked from Interrupt Service Routines.
For the complete definition, see
os::rtos::mutex::owner()

Definition at line 1895 of file os-c-wrapper.cpp.

1896{
1897 assert (mutex != nullptr);
1898 return (os_thread_t*)(reinterpret_cast<rtos::mutex&> (*mutex)).owner ();
1899}

◆ os_mutex_get_prio_ceiling()

os_thread_prio_t os_mutex_get_prio_ceiling ( os_mutex_t mutex)
Parameters
[in]mutexPointer to mutex object instance.
Returns
The priority ceiling.
Warning
Cannot be invoked from Interrupt Service Routines.
For the complete definition, see
os::rtos::mutex::prio_ceiling()

Definition at line 1852 of file os-c-wrapper.cpp.

1853{
1854 assert (mutex != nullptr);
1855 return (os_thread_prio_t)(reinterpret_cast<rtos::mutex&> (*mutex))
1856 .prio_ceiling ();
1857}

◆ os_mutex_get_protocol()

os_mutex_protocol_t os_mutex_get_protocol ( os_mutex_t mutex)
Parameters
[in]mutexPointer to mutex object instance.
Returns
An integer encoding the os::rtos::mutex::protocol.
Warning
Cannot be invoked from Interrupt Service Routines.
For the complete definition, see
os::rtos::mutex::protocol()

Definition at line 1921 of file os-c-wrapper.cpp.

1922{
1923 assert (mutex != nullptr);
1924 return (reinterpret_cast<rtos::mutex&> (*mutex)).protocol ();
1925}

◆ os_mutex_get_robustness()

os_mutex_robustness_t os_mutex_get_robustness ( os_mutex_t mutex)
Parameters
[in]mutexPointer to mutex object instance.
Returns
An integer encoding the os::rtos::mutex::robustness.
Warning
Cannot be invoked from Interrupt Service Routines.
For the complete definition, see
os::rtos::mutex::robustness()

Definition at line 1934 of file os-c-wrapper.cpp.

1935{
1936 assert (mutex != nullptr);
1937 return (reinterpret_cast<rtos::mutex&> (*mutex)).robustness ();
1938}

◆ os_mutex_get_type()

os_mutex_type_t os_mutex_get_type ( os_mutex_t mutex)
Parameters
[in]mutexPointer to mutex object instance.
Returns
An integer encoding the os::rtos::mutex::type.
Warning
Cannot be invoked from Interrupt Service Routines.
For the complete definition, see
os::rtos::mutex::type()

Definition at line 1908 of file os-c-wrapper.cpp.

1909{
1910 assert (mutex != nullptr);
1911 return (reinterpret_cast<rtos::mutex&> (*mutex)).type ();
1912}

◆ os_mutex_lock()

os_result_t os_mutex_lock ( os_mutex_t mutex)
Parameters
[in]mutexPointer to mutex object instance.
Return values
os_okThe mutex was locked.
EPERMCannot be invoked from an Interrupt Service Routines.
ENOTRECOVERABLEThe state protected by the mutex is not recoverable..
EAGAINThe mutex could not be acquired because the maximum number of recursive locks for mutex has been exceeded.
EINVALThe 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.
EOWNERDEADThe 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.
EDEADLKThe mutex type is os_mutex_type_errorcheck and the current thread already owns the mutex.
Warning
Cannot be invoked from Interrupt Service Routines.
For the complete definition, see
os::rtos::mutex::lock()

Definition at line 1799 of file os-c-wrapper.cpp.

1800{
1801 assert (mutex != nullptr);
1802 return (os_result_t)(reinterpret_cast<rtos::mutex&> (*mutex)).lock ();
1803}
uint32_t os_result_t
Type of values returned by RTOS functions.
Definition os-c-decls.h:94

◆ os_mutex_mark_consistent()

os_result_t os_mutex_mark_consistent ( os_mutex_t mutex)
Parameters
[in]mutexPointer to mutex object instance.
Return values
os_okThe mutex was marked as consistent.
EPERMCannot be invoked from an Interrupt Service Routines.
EINVALThe mutex object referenced by mutex is not robust or does not protect an inconsistent state.
Warning
Cannot be invoked from Interrupt Service Routines.
For the complete definition, see
os::rtos::mutex::consistent()

Definition at line 1882 of file os-c-wrapper.cpp.

1883{
1884 assert (mutex != nullptr);
1885 return (os_result_t)(reinterpret_cast<rtos::mutex&> (*mutex)).consistent ();
1886}

◆ os_mutex_new()

os_mutex_t * os_mutex_new ( const char *  name,
const os_mutex_attr_t attr 
)
Parameters
[in]namePointer to name (may be NULL).
[in]attrPointer to attributes (may be NULL).
Returns
Pointer to new mutex object instance.

Dynamically allocate the mutex object instance using the RTOS system allocator and construct it.

Note
Equivalent of C++ new mutex(...).
Must be paired with os_mutex_delete().
Warning
Cannot be invoked from Interrupt Service Routines.
For the complete definition, see
os::rtos::mutex

Definition at line 1724 of file os-c-wrapper.cpp.

1725{
1726 if (attr == nullptr)
1727 {
1729 }
1730 return reinterpret_cast<os_mutex_t*> (
1731 new rtos::mutex (name, (const mutex::attributes&)*attr));
1732}

References os::rtos::mutex::initializer_normal.

◆ os_mutex_recursive_construct()

void os_mutex_recursive_construct ( os_mutex_t mutex,
const char *  name,
const os_mutex_attr_t attr 
)
Parameters
[in]mutexPointer to mutex object instance storage.
[in]namePointer to name (may be NULL).
[in]attrPointer to attributes (may be NULL).
Returns
Nothing.
Note
Must be paired with os_mutex_destruct().
Warning
Cannot be invoked from Interrupt Service Routines.
For the complete definition, see
os::rtos::mutex_recursive

Definition at line 1683 of file os-c-wrapper.cpp.

1685{
1686 assert (mutex != nullptr);
1687 if (attr == nullptr)
1688 {
1690 }
1691 new (mutex) rtos::mutex_recursive (name, (const mutex::attributes&)*attr);
1692}
POSIX compliant recursive mutex.
Definition os-mutex.h:703

References os::rtos::mutex::initializer_recursive.

◆ os_mutex_recursive_new()

os_mutex_t * os_mutex_recursive_new ( const char *  name,
const os_mutex_attr_t attr 
)
Parameters
[in]namePointer to name (may be NULL).
[in]attrPointer to attributes (may be NULL).
Returns
Pointer to new recursive mutex object instance.

Dynamically allocate the recursive mutex object instance using the RTOS system allocator and construct it.

Note
Equivalent of C++ new mutex_recursive(...).
Must be paired with os_mutex_delete().
Warning
Cannot be invoked from Interrupt Service Routines.
For the complete definition, see
os::rtos::mutex_recursive

Definition at line 1748 of file os-c-wrapper.cpp.

1749{
1750 if (attr == nullptr)
1751 {
1753 }
1754 return reinterpret_cast<os_mutex_t*> (
1755 new rtos::mutex_recursive (name, (const mutex::attributes&)*attr));
1756}

References os::rtos::mutex::initializer_recursive.

◆ os_mutex_reset()

os_result_t os_mutex_reset ( os_mutex_t mutex)
Parameters
[in]mutexPointer to mutex object instance.
Return values
os_okThe mutex was reset.
Warning
Cannot be invoked from Interrupt Service Routines.
For the complete definition, see
os::rtos::mutex::reset()

Definition at line 1947 of file os-c-wrapper.cpp.

1948{
1949 assert (mutex != nullptr);
1950 return (os_result_t)(reinterpret_cast<rtos::mutex&> (*mutex)).reset ();
1951}

◆ os_mutex_set_prio_ceiling()

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 
)
Parameters
[in]mutexPointer to mutex object instance.
[in]prio_ceilingnew priority.
[out]old_prio_ceilingpointer to location where to store the previous priority; may be NULL.
Return values
os_okThe priority was changed.
EPERMCannot be invoked from an Interrupt Service Routines.
Warning
Cannot be invoked from Interrupt Service Routines.
For the complete definition, see
os::rtos::mutex::prio_ceiling(os::rtos::thread::priority_t, os::rtos::thread::priority_t*)

Definition at line 1867 of file os-c-wrapper.cpp.

1869{
1870 assert (mutex != nullptr);
1871 return (os_result_t)(reinterpret_cast<rtos::mutex&> (*mutex))
1872 .prio_ceiling (prio_ceiling, old_prio_ceiling);
1873}

◆ os_mutex_timed_lock()

os_result_t os_mutex_timed_lock ( os_mutex_t mutex,
os_clock_duration_t  timeout 
)
Parameters
[in]mutexPointer to mutex object instance.
[in]timeoutTimeout to wait, in clock units (ticks or seconds).
Return values
os_okThe mutex was locked.
EPERMCannot be invoked from an Interrupt Service Routines.
ETIMEDOUTThe mutex could not be locked before the specified timeout expired.
ENOTRECOVERABLEThe state protected by the mutex is not recoverable.
EAGAINThe mutex could not be acquired because the maximum number of recursive locks for mutex has been exceeded.
EDEADLKThe mutex type is os_mutex_type_errorcheck and the current thread already owns the mutex.
EINVALThe process or thread would have blocked, and the timeout parameter is invalid.
EOWNERDEADThe 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.
Warning
Cannot be invoked from Interrupt Service Routines.
For the complete definition, see
os::rtos::mutex::timed_lock()

Definition at line 1825 of file os-c-wrapper.cpp.

1826{
1827 assert (mutex != nullptr);
1828 return (os_result_t)(reinterpret_cast<rtos::mutex&> (*mutex))
1829 .timed_lock (timeout);
1830}

◆ os_mutex_try_lock()

os_result_t os_mutex_try_lock ( os_mutex_t mutex)
Parameters
[in]mutexPointer to mutex object instance.
Return values
os_okThe mutex was locked.
EPERMCannot be invoked from an Interrupt Service Routines.
ENOTRECOVERABLEThe state protected by the mutex is not recoverable..
EAGAINThe mutex could not be acquired because the maximum number of recursive locks for mutex has been exceeded.
EINVALThe 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.
EOWNERDEADThe 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.
EDEADLKThe mutex type is os_mutex_type_errorcheck and the current thread already owns the mutex.
EWOULDBLOCKThe mutex could not be acquired because it was already locked.
Warning
Cannot be invoked from Interrupt Service Routines.
For the complete definition, see
os::rtos::mutex::try_lock()

Definition at line 1812 of file os-c-wrapper.cpp.

1813{
1814 assert (mutex != nullptr);
1815 return (os_result_t)(reinterpret_cast<rtos::mutex&> (*mutex)).try_lock ();
1816}

◆ os_mutex_unlock()

os_result_t os_mutex_unlock ( os_mutex_t mutex)
Parameters
[in]mutexPointer to mutex object instance.
Return values
os_okThe mutex was unlocked.
EPERMCannot 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.
ENOTRECOVERABLEThe mutex was not unlocked.
Warning
Cannot be invoked from Interrupt Service Routines.
For the complete definition, see
os::rtos::mutex::unlock()

Definition at line 1839 of file os-c-wrapper.cpp.

1840{
1841 assert (mutex != nullptr);
1842 return (os_result_t)(reinterpret_cast<rtos::mutex&> (*mutex)).unlock ();
1843}