C API condition variable definitions.
More...
- For the complete definition, see
- RTOS C++ API
- Examples
int
{
{
}
}
os_result_t os_condvar_signal(os_condvar_t *condvar)
Notify one thread waiting for a condition variable.
void os_condvar_construct(os_condvar_t *condvar, const char *name, const os_condvar_attr_t *attr)
Construct a statically allocated condition variable object instance.
void os_condvar_destruct(os_condvar_t *condvar)
Destruct the statically allocated condition variable object instance.
const char * os_condvar_get_name(os_condvar_t *condvar)
Get the condition variable name.
os_result_t os_condvar_broadcast(os_condvar_t *condvar)
Notify all threads waiting for a condition variable.
int os_main(int argc, char *argv[])
Application entry point, running on the main thread context.
Condition variable object storage.
◆ os_condvar_create
◆ os_condvar_destroy
◆ os_condvar_attr_t
◆ os_condvar_t
◆ os_condvar_attr_init()
- Parameters
-
| [in] | attr | Pointer to condition variable attributes object instance. |
- Returns
- Nothing.
- Warning
- Cannot be invoked from Interrupt Service Routines.
- For the complete definition, see
- os::rtos::condition_variable::attributes
Definition at line 1962 of file os-c-wrapper.cpp.
1963{
1964 assert (attr != nullptr);
1966}
Condition variable attributes.
◆ os_condvar_broadcast()
- Parameters
-
| [in] | condvar | Pointer to condition variable object instance. |
- Return values
-
| os_ok | All waiting threads signalled. |
| EPERM | Cannot be invoked from an Interrupt Service Routines. |
- Errors
- The function shall not fail with an error code of
EINTR.
- Warning
- Cannot be invoked from Interrupt Service Routines.
- For the complete definition, see
- os::rtos::condition_variable::broadcast()
Definition at line 2082 of file os-c-wrapper.cpp.
2083{
2084 assert (condvar != nullptr);
2086 .broadcast ();
2087}
POSIX compliant condition variable.
uint32_t os_result_t
Type of values returned by RTOS functions.
◆ os_condvar_construct()
- Parameters
-
| [in] | condvar | Pointer to condition variable object instance storage. |
| [in] | name | Pointer to name (may be NULL). |
| [in] | attr | Pointer to attributes (may be NULL). |
- Errors
- The constructor shall fail if:
EAGAIN - The system lacked the necessary resources (other than memory) to create the condition variable.
ENOMEM - Insufficient memory exists to initialise the condition variable.
- The constructor shall not fail with an error code of
EINTR.
- Returns
- Nothing.
- Note
- Must be paired with
os_condvar_destruct().
- Warning
- Cannot be invoked from Interrupt Service Routines.
- For the complete definition, see
- os::rtos::condition_variable
Definition at line 1977 of file os-c-wrapper.cpp.
1979{
1980 assert (condvar != nullptr);
1981 if (attr == nullptr)
1982 {
1984 }
1985 new (condvar)
1987}
static const attributes initializer
Default condition variable initialiser.
Condition variable attributes.
References os::rtos::condition_variable::initializer.
◆ os_condvar_delete()
- Parameters
-
| [in] | condvar | Pointer to dynamically allocated condition variable object instance. |
- Returns
- Nothing.
Destruct the condition variable and deallocate the dynamically allocated space using the RTOS system allocator.
- Note
- Equivalent of C++
delete ptr_condvar.
-
Must be paired with
os_condvar_new().
- Warning
- Cannot be invoked from Interrupt Service Routines.
- For the complete definition, see
- os::rtos::condition_variable
Definition at line 2042 of file os-c-wrapper.cpp.
2043{
2044 assert (condvar != nullptr);
2046}
◆ os_condvar_destruct()
◆ os_condvar_get_name()
- Parameters
-
| [in] | condvar | Pointer to condition variable object instance. |
- Returns
- Null terminated string.
- Note
- Can be invoked from Interrupt Service Routines.
- For the complete definition, see
- os::rtos::condition_variable::name()
Definition at line 2055 of file os-c-wrapper.cpp.
2056{
2057 assert (condvar != nullptr);
2059}
◆ os_condvar_new()
- Parameters
-
| [in] | name | Pointer to name (may be NULL). |
| [in] | attr | Pointer to attributes (may be NULL). |
- Errors
- The constructor shall fail if:
EAGAIN - The system lacked the necessary resources (other than memory) to create the condition variable.
ENOMEM - Insufficient memory exists to initialise the condition variable.
- The constructor shall not fail with an error code of
EINTR.
- Returns
- Pointer to new condition variable object instance.
Dynamically allocate the condition variable object instance using the RTOS system allocator and construct it.
- Note
- Equivalent of C++
new condition_variable(...).
-
Must be paired with
os_condvar_delete().
- Warning
- Cannot be invoked from Interrupt Service Routines.
- For the complete definition, see
- os::rtos::condition_variable
Definition at line 2018 of file os-c-wrapper.cpp.
2019{
2020 if (attr == nullptr)
2021 {
2023 }
2026}
References os::rtos::condition_variable::initializer.
◆ os_condvar_signal()
- Parameters
-
| [in] | condvar | Pointer to condition variable object instance. |
- Return values
-
| os_ok | The thread was signalled. |
| EPERM | Cannot be invoked from an Interrupt Service Routines. |
- Errors
- The function shall not fail with an error code of
EINTR.
- Warning
- Cannot be invoked from Interrupt Service Routines.
- For the complete definition, see
- os::rtos::condition_variable::signal()
Definition at line 2068 of file os-c-wrapper.cpp.
2069{
2070 assert (condvar != nullptr);
2072 .signal ();
2073}
◆ os_condvar_timed_wait()
- Parameters
-
| [in] | condvar | Pointer to condition variable object instance. |
| [in] | mutex | Pointer to the associated mutex. |
| [in] | timeout | Timeout to wait. |
- Return values
-
| os_ok | The condition change was signalled. |
| EPERM | Cannot be invoked from an Interrupt Service Routines, or the mutex type is mutex::type::errorcheck or the mutex is a robust mutex, and the current thread does not own the mutex. |
| ENOTRECOVERABLE | The state protected by the mutex is not recoverable. |
| 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. |
| ETIMEDOUT | The timeout has passed. |
- Errors
- The function shall not fail with an error code of
EINTR.
- Warning
- Cannot be invoked from Interrupt Service Routines.
- For the complete definition, see
- os::rtos::condition_variable::timed_wait()
Definition at line 2110 of file os-c-wrapper.cpp.
2112{
2113 assert (condvar != nullptr);
2116}
◆ os_condvar_wait()
- Parameters
-
| [in] | condvar | Pointer to condition variable object instance. |
| [in] | mutex | Pointer to the associated mutex. |
- Return values
-
| os_ok | The condition change was signalled. |
| EPERM | Cannot be invoked from an Interrupt Service Routines, or the mutex type is mutex::type::errorcheck or the mutex is a robust mutex, and the current thread does not own the mutex. |
| ENOTRECOVERABLE | The state protected by the mutex is not recoverable. |
| 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. |
- Errors
- The function shall not fail with an error code of
EINTR.
- Warning
- Cannot be invoked from Interrupt Service Routines.
- For the complete definition, see
- os::rtos::condition_variable::wait()
Definition at line 2096 of file os-c-wrapper.cpp.
2097{
2098 assert (condvar != nullptr);
2101}
pid_t wait(int *stat_loc)
References wait().