Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • kernel/generic/src/synch/condvar.c

    re88eb48 r111b9b9  
    5858void condvar_signal(condvar_t *cv)
    5959{
    60         waitq_wakeup(&cv->wq, WAKEUP_FIRST);
     60        waitq_signal(&cv->wq);
    6161}
    6262
     
    6868void condvar_broadcast(condvar_t *cv)
    6969{
    70         waitq_wakeup(&cv->wq, WAKEUP_ALL);
     70        waitq_wake_all(&cv->wq);
    7171}
    7272
     
    7676 * @param mtx           Mutex.
    7777 * @param usec          Timeout value in microseconds.
    78  * @param flags         Select mode of operation.
    79  *
    80  * For exact description of meaning of possible combinations of usec and flags,
    81  * see comment for waitq_sleep_timeout().  Note that when
    82  * SYNCH_FLAGS_NON_BLOCKING is specified here, EAGAIN is always
    83  * returned.
    8478 *
    8579 * @return              See comment for waitq_sleep_timeout().
    8680 */
    87 errno_t _condvar_wait_timeout(condvar_t *cv, mutex_t *mtx, uint32_t usec, int flags)
     81errno_t condvar_wait_timeout(condvar_t *cv, mutex_t *mtx, uint32_t usec)
    8882{
    89         errno_t rc;
    90         ipl_t ipl;
    91         bool blocked;
     83        wait_guard_t guard = waitq_sleep_prepare(&cv->wq);
    9284
    93         ipl = waitq_sleep_prepare(&cv->wq);
    9485        /* Unlock only after the waitq is locked so we don't miss a wakeup. */
    9586        mutex_unlock(mtx);
    9687
    97         cv->wq.missed_wakeups = 0;      /* Enforce blocking. */
    98         rc = waitq_sleep_timeout_unsafe(&cv->wq, usec, flags, &blocked);
    99         assert(blocked || rc != EOK);
     88        errno_t rc = waitq_sleep_timeout_unsafe(&cv->wq, usec, SYNCH_FLAGS_NON_BLOCKING, guard);
    10089
    101         waitq_sleep_finish(&cv->wq, blocked, ipl);
    102         /* Lock only after releasing the waitq to avoid a possible deadlock. */
    10390        mutex_lock(mtx);
     91        return rc;
     92}
    10493
     94errno_t condvar_wait(condvar_t *cv, mutex_t *mtx)
     95{
     96        wait_guard_t guard = waitq_sleep_prepare(&cv->wq);
     97
     98        /* Unlock only after the waitq is locked so we don't miss a wakeup. */
     99        mutex_unlock(mtx);
     100
     101        errno_t rc = waitq_sleep_unsafe(&cv->wq, guard);
     102
     103        mutex_lock(mtx);
    105104        return rc;
    106105}
     
    127126    uint32_t usec, int flags)
    128127{
    129         errno_t rc;
    130         ipl_t ipl;
    131         bool blocked;
    132 
    133         ipl = waitq_sleep_prepare(&cv->wq);
     128        wait_guard_t guard = waitq_sleep_prepare(&cv->wq);
    134129
    135130        /* Unlock only after the waitq is locked so we don't miss a wakeup. */
    136131        spinlock_unlock(lock);
    137132
    138         cv->wq.missed_wakeups = 0;      /* Enforce blocking. */
    139         rc = waitq_sleep_timeout_unsafe(&cv->wq, usec, flags, &blocked);
    140         assert(blocked || rc != EOK);
     133        errno_t rc = waitq_sleep_timeout_unsafe(&cv->wq, usec, flags, guard);
    141134
    142         waitq_sleep_finish(&cv->wq, blocked, ipl);
    143         /* Lock only after releasing the waitq to avoid a possible deadlock. */
    144135        spinlock_lock(lock);
    145 
    146136        return rc;
    147137}
Note: See TracChangeset for help on using the changeset viewer.