35,11 → 35,11 |
#include <synch/mutex.h> |
#include <synch/waitq.h> |
#include <synch/synch.h> |
#include <arch.h> |
#include <typedefs.h> |
|
/** Initialize condition variable |
/** Initialize condition variable. |
* |
* Initialize condition variable. |
* |
* @param cv Condition variable. |
*/ |
void condvar_initialize(condvar_t *cv) |
47,8 → 47,7 |
waitq_initialize(&cv->wq); |
} |
|
/** Signal the condition has become true |
* |
/** |
* Signal the condition has become true |
* to the first waiting thread by waking it up. |
* |
59,8 → 58,7 |
waitq_wakeup(&cv->wq, WAKEUP_FIRST); |
} |
|
/** Signal the condition has become true |
* |
/** |
* Signal the condition has become true |
* to all waiting threads by waking them up. |
* |
71,10 → 69,8 |
waitq_wakeup(&cv->wq, WAKEUP_ALL); |
} |
|
/** Wait for the condition becoming true |
/** Wait for the condition becoming true. |
* |
* Wait for the condition becoming true. |
* |
* @param cv Condition variable. |
* @param mtx Mutex. |
* @param usec Timeout value in microseconds. |
88,9 → 84,15 |
int _condvar_wait_timeout(condvar_t *cv, mutex_t *mtx, __u32 usec, int trywait) |
{ |
int rc; |
ipl_t ipl; |
|
ipl = waitq_sleep_prepare(&cv->wq); |
mutex_unlock(mtx); |
rc = waitq_sleep_timeout(&cv->wq, usec, trywait); |
|
rc = waitq_sleep_timeout_unsafe(&cv->wq, usec, trywait); |
|
mutex_lock(mtx); |
waitq_sleep_finish(&cv->wq, rc, ipl); |
|
return rc; |
} |