Changes in kernel/generic/src/synch/condvar.c [e88eb48:111b9b9] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/generic/src/synch/condvar.c
re88eb48 r111b9b9 58 58 void condvar_signal(condvar_t *cv) 59 59 { 60 waitq_ wakeup(&cv->wq, WAKEUP_FIRST);60 waitq_signal(&cv->wq); 61 61 } 62 62 … … 68 68 void condvar_broadcast(condvar_t *cv) 69 69 { 70 waitq_wake up(&cv->wq, WAKEUP_ALL);70 waitq_wake_all(&cv->wq); 71 71 } 72 72 … … 76 76 * @param mtx Mutex. 77 77 * @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 when82 * SYNCH_FLAGS_NON_BLOCKING is specified here, EAGAIN is always83 * returned.84 78 * 85 79 * @return See comment for waitq_sleep_timeout(). 86 80 */ 87 errno_t _condvar_wait_timeout(condvar_t *cv, mutex_t *mtx, uint32_t usec, int flags)81 errno_t condvar_wait_timeout(condvar_t *cv, mutex_t *mtx, uint32_t usec) 88 82 { 89 errno_t rc; 90 ipl_t ipl; 91 bool blocked; 83 wait_guard_t guard = waitq_sleep_prepare(&cv->wq); 92 84 93 ipl = waitq_sleep_prepare(&cv->wq);94 85 /* Unlock only after the waitq is locked so we don't miss a wakeup. */ 95 86 mutex_unlock(mtx); 96 87 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); 100 89 101 waitq_sleep_finish(&cv->wq, blocked, ipl);102 /* Lock only after releasing the waitq to avoid a possible deadlock. */103 90 mutex_lock(mtx); 91 return rc; 92 } 104 93 94 errno_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); 105 104 return rc; 106 105 } … … 127 126 uint32_t usec, int flags) 128 127 { 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); 134 129 135 130 /* Unlock only after the waitq is locked so we don't miss a wakeup. */ 136 131 spinlock_unlock(lock); 137 132 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); 141 134 142 waitq_sleep_finish(&cv->wq, blocked, ipl);143 /* Lock only after releasing the waitq to avoid a possible deadlock. */144 135 spinlock_lock(lock); 145 146 136 return rc; 147 137 }
Note:
See TracChangeset
for help on using the changeset viewer.