Zephyr API Documentation 4.0.99
A Scalable Open Source RTOS
|
Functions | |
int | k_futex_wait (struct k_futex *futex, int expected, k_timeout_t timeout) |
Pend the current thread on a futex. | |
int | k_futex_wake (struct k_futex *futex, bool wake_all) |
Wake one/all threads pending on a futex. | |
int k_futex_wait | ( | struct k_futex * | futex, |
int | expected, | ||
k_timeout_t | timeout ) |
#include <zephyr/kernel.h>
Pend the current thread on a futex.
Tests that the supplied futex contains the expected value, and if so, goes to sleep until some other thread calls k_futex_wake() on it.
futex | Address of the futex. |
expected | Expected value of the futex, if it is different the caller will not wait on it. |
timeout | Waiting period on the futex, or one of the special values K_NO_WAIT or K_FOREVER. |
-EACCES | Caller does not have read access to futex address. |
-EAGAIN | If the futex value did not match the expected parameter. |
-EINVAL | Futex parameter address not recognized by the kernel. |
-ETIMEDOUT | Thread woke up due to timeout and not a futex wakeup. |
0 | if the caller went to sleep and was woken up. The caller should check the futex's value on wakeup to determine if it needs to block again. |
#include <zephyr/kernel.h>
Wake one/all threads pending on a futex.
Wake up the highest priority thread pending on the supplied futex, or wakeup all the threads pending on the supplied futex, and the behavior depends on wake_all.
futex | Futex to wake up pending threads. |
wake_all | If true, wake up all pending threads; If false, wakeup the highest priority thread. |
-EACCES | Caller does not have access to the futex address. |
-EINVAL | Futex parameter address not recognized by the kernel. |
Number | of threads that were woken up. |