Condition variable primitives for threads waiting on a shared predicate.
More...
|
|
#define | SYS_COND_CAPACITY 32 |
| | Maximum number of condition variables available in static-pool implementations.
|
| |
Condition variable primitives for threads waiting on a shared predicate.
◆ sys_cond_broadcast()
Signal all waiting threads.
- Parameters
-
| cond | Pointer to the condition variable to broadcast |
- Returns
- true if successful, false on error
Wakes up all threads waiting on the condition variable. If no threads are waiting, this function has no effect. The associated mutex should be locked when calling this function for predictable behavior.
◆ sys_cond_deinit()
Deinitialize a condition variable.
- Parameters
-
| cond | Pointer to the condition variable to deinitialize |
Releases all resources associated with the condition variable and renders it unusable. No threads should be waiting on the condition variable when this function is called.
◆ sys_cond_init()
Initialize a new condition variable.
- Returns
- Initialized condition variable structure
Creates and initializes a new condition variable for thread synchronization. The condition variable is ready for use with wait/signal operations. The returned condition variable must be deinitialized with sys_cond_deinit()
◆ sys_cond_signal()
Signal one waiting thread.
- Parameters
-
| cond | Pointer to the condition variable to signal |
- Returns
- true if successful, false on error
Wakes up one thread waiting on the condition variable. If no threads are waiting, this function has no effect. The associated mutex should be locked when calling this function for predictable behavior.
◆ sys_cond_timedwait()
Wait on a condition variable with timeout.
- Parameters
-
| cond | Pointer to the condition variable to wait on |
| mutex | Pointer to the mutex that must be locked by the calling thread |
| timeout_ms | Timeout in milliseconds (0 = no timeout) |
- Returns
- true if signaled, false if timeout or error
Like sys_cond_wait() but returns after timeout_ms milliseconds if not signaled. Returns true if signaled, false if timeout or error occurred.
◆ sys_cond_wait()
Wait on a condition variable.
- Parameters
-
| cond | Pointer to the condition variable to wait on |
| mutex | Pointer to the mutex that must be locked by the calling thread |
- Returns
- true if the wait completed successfully, false on error
Atomically releases the mutex and waits for the condition variable to be signaled. Upon return, the mutex is reacquired. The mutex must be locked by the calling thread before calling this function.