Subversion Repositories HelenOS-historic

Rev

Rev 1375 | Rev 1502 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 1375 Rev 1416
Line 72... Line 72...
72
/** Wait for the condition becoming true.
72
/** Wait for the condition becoming true.
73
 *
73
 *
74
 * @param cv Condition variable.
74
 * @param cv Condition variable.
75
 * @param mtx Mutex.
75
 * @param mtx Mutex.
76
 * @param usec Timeout value in microseconds.
76
 * @param usec Timeout value in microseconds.
77
 * @param trywait Blocking versus non-blocking operation mode switch.
-
 
78
 *
77
 *
79
 * For exact description of possible combinations of
78
 * For exact description of meaning of possible values of usec,
80
 * usec and trywait, see comment for waitq_sleep_timeout().
79
 * see comment for waitq_sleep_timeout().
81
 *
80
 *
82
 * @return See comment for waitq_sleep_timeout().
81
 * @return See comment for waitq_sleep_timeout().
83
 */
82
 */
84
int _condvar_wait_timeout(condvar_t *cv, mutex_t *mtx, __u32 usec, int trywait)
83
int _condvar_wait_timeout(condvar_t *cv, mutex_t *mtx, __u32 usec)
85
{
84
{
86
    int rc;
85
    int rc;
87
    ipl_t ipl;
86
    ipl_t ipl;
88
 
87
 
89
    ipl = waitq_sleep_prepare(&cv->wq);
88
    ipl = waitq_sleep_prepare(&cv->wq);
90
    mutex_unlock(mtx);
89
    mutex_unlock(mtx);
91
   
90
 
-
 
91
    cv->wq.missed_wakeups = 0;  /* Enforce blocking. */
92
    rc = waitq_sleep_timeout_unsafe(&cv->wq, usec, trywait);
92
    rc = waitq_sleep_timeout_unsafe(&cv->wq, usec, SYNCH_BLOCKING);
93
 
93
 
94
    mutex_lock(mtx);
94
    mutex_lock(mtx);
95
    waitq_sleep_finish(&cv->wq, rc, ipl);
95
    waitq_sleep_finish(&cv->wq, rc, ipl);
96
 
96
 
97
    return rc;
97
    return rc;