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