#include "condvar.h"
#include "errnums.h"
#include "debug.h"
#include "int.h"
#include "timers.h"
#include "io.h"
#include "mutex.h"
Functions | |
void | cond_init (cond_t *cvar) |
Initialize condition variable. | |
void | cond_destroy (cond_t *cvar) |
Destroys conditional variable. | |
void | cond_signal (cond_t *cvar) |
Unlock one of threads waiting on the condition variable. | |
void | cond_broadcast (cond_t *cvar) |
Unlock all of threads waiting on the condition variable. | |
void | cond_wait (cond_t *cvar, struct mutex *mtx) |
Suspend calling thread on a condition variable waiting for condition Atomically unlocks mutex and suspends calling thread on conditional variable after waking up locks mutex. | |
int | cond_wait_timeout (cond_t *cvar, mutex_t *mtx, const unsigned int usec) |
Atomically unlocks mutex and suspends calling thread at most on \ usec microseconds. |
Conditional variables are implemented as a queue of threads waiting for the condition, that allows to wakeup them on cond_wait and cond signal calls.
This file is based on Kalisto, Development Kernel copyrighted (c) to Distributed Systems Research Group MFF UK, Czech republic.
void cond_broadcast | ( | cond_t * | cvar | ) |
Unlock all of threads waiting on the condition variable.
cvar | condition variable struct pointer |
void cond_destroy | ( | cond_t * | cvar | ) |
Destroys conditional variable.
cvar | condition variable struct pointer |
void cond_init | ( | cond_t * | cvar | ) |
Initialize condition variable.
cvar | condition variable struct pointer |
void cond_signal | ( | cond_t * | cvar | ) |
Unlock one of threads waiting on the condition variable.
cvar | condition variable struct pointer |
Suspend calling thread on a condition variable waiting for condition Atomically unlocks mutex and suspends calling thread on conditional variable after waking up locks mutex.
cvar | condition variable pointer | |
mtx | mutex pointer |
Atomically unlocks mutex and suspends calling thread at most on \ usec microseconds.
If 0 msec is wanted thread suspend is ommitted, but the thread yield one times before next mutex lock
cvar | condition variable struct pointer | |
mtx | mutex pointer | |
usec | time limit to wait |