Zephyr API Documentation
3.6.99
A Scalable Open Source RTOS
|
Macros | |
#define | K_CONDVAR_DEFINE(name) |
Statically define and initialize a condition variable. | |
Functions | |
int | k_condvar_init (struct k_condvar *condvar) |
Initialize a condition variable. | |
int | k_condvar_signal (struct k_condvar *condvar) |
Signals one thread that is pending on the condition variable. | |
int | k_condvar_broadcast (struct k_condvar *condvar) |
Unblock all threads that are pending on the condition variable. | |
int | k_condvar_wait (struct k_condvar *condvar, struct k_mutex *mutex, k_timeout_t timeout) |
Waits on the condition variable releasing the mutex lock. | |
#define K_CONDVAR_DEFINE | ( | name | ) |
#include <zephyr/kernel.h>
Statically define and initialize a condition variable.
The condition variable can be accessed outside the module where it is defined using:
name | Name of the condition variable. |
int k_condvar_broadcast | ( | struct k_condvar * | condvar | ) |
#include <zephyr/kernel.h>
Unblock all threads that are pending on the condition variable.
condvar | pointer to a k_condvar structure |
int k_condvar_init | ( | struct k_condvar * | condvar | ) |
#include <zephyr/kernel.h>
Initialize a condition variable.
condvar | pointer to a k_condvar structure |
0 | Condition variable created successfully |
int k_condvar_signal | ( | struct k_condvar * | condvar | ) |
#include <zephyr/kernel.h>
Signals one thread that is pending on the condition variable.
condvar | pointer to a k_condvar structure |
0 | On success |
int k_condvar_wait | ( | struct k_condvar * | condvar, |
struct k_mutex * | mutex, | ||
k_timeout_t | timeout | ||
) |
#include <zephyr/kernel.h>
Waits on the condition variable releasing the mutex lock.
Atomically releases the currently owned mutex, blocks the current thread waiting on the condition variable specified by condvar, and finally acquires the mutex again.
The waiting thread unblocks only after another thread calls k_condvar_signal, or k_condvar_broadcast with the same condition variable.
condvar | pointer to a k_condvar structure |
mutex | Address of the mutex. |
timeout | Waiting period for the condition variable or one of the special values K_NO_WAIT and K_FOREVER. |
0 | On success |
-EAGAIN | Waiting period timed out. |