Changeset 5110d0a in mainline for kernel/generic/src/synch/condvar.c
- Timestamp:
- 2023-02-07T16:02:50Z (15 months ago)
- Branches:
- master, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 7c5320c
- Parents:
- 8a55346
- git-author:
- Jiří Zárevúcky <zarevucky.jiri@…> (2023-02-06 16:44:26)
- git-committer:
- Jiří Zárevúcky <zarevucky.jiri@…> (2023-02-07 16:02:50)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/generic/src/synch/condvar.c
r8a55346 r5110d0a 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 83 errno_t rc; … … 96 90 97 91 cv->wq.missed_wakeups = 0; /* Enforce blocking. */ 98 rc = waitq_sleep_timeout_unsafe(&cv->wq, usec, flags, &blocked); 92 rc = waitq_sleep_timeout_unsafe(&cv->wq, usec, SYNCH_FLAGS_NON_BLOCKING, &blocked); 93 assert(blocked || rc != EOK); 94 95 waitq_sleep_finish(&cv->wq, blocked, ipl); 96 /* Lock only after releasing the waitq to avoid a possible deadlock. */ 97 mutex_lock(mtx); 98 99 return rc; 100 } 101 102 errno_t condvar_wait(condvar_t *cv, mutex_t *mtx) 103 { 104 errno_t rc; 105 ipl_t ipl; 106 bool blocked; 107 108 ipl = waitq_sleep_prepare(&cv->wq); 109 /* Unlock only after the waitq is locked so we don't miss a wakeup. */ 110 mutex_unlock(mtx); 111 112 cv->wq.missed_wakeups = 0; /* Enforce blocking. */ 113 rc = waitq_sleep_unsafe(&cv->wq, &blocked); 99 114 assert(blocked || rc != EOK); 100 115
Note:
See TracChangeset
for help on using the changeset viewer.