Changeset 111b9b9 in mainline for kernel/generic/src/synch/condvar.c
- Timestamp:
- 2023-02-11T19:13:44Z (2 years ago)
- Branches:
- master, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 4777e02
- Parents:
- 76e17d7c
- git-author:
- Jiří Zárevúcky <zarevucky.jiri@…> (2022-08-15 17:46:39)
- git-committer:
- Jiří Zárevúcky <zarevucky.jiri@…> (2023-02-11 19:13:44)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/generic/src/synch/condvar.c
r76e17d7c 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 … … 81 81 errno_t condvar_wait_timeout(condvar_t *cv, mutex_t *mtx, uint32_t usec) 82 82 { 83 errno_t rc; 84 ipl_t ipl; 85 bool blocked; 83 wait_guard_t guard = waitq_sleep_prepare(&cv->wq); 86 84 87 ipl = waitq_sleep_prepare(&cv->wq);88 85 /* Unlock only after the waitq is locked so we don't miss a wakeup. */ 89 86 mutex_unlock(mtx); 90 87 91 cv->wq.missed_wakeups = 0; /* Enforce blocking. */ 92 rc = waitq_sleep_timeout_unsafe(&cv->wq, usec, SYNCH_FLAGS_NON_BLOCKING, &blocked); 93 assert(blocked || rc != EOK); 88 errno_t rc = waitq_sleep_timeout_unsafe(&cv->wq, usec, SYNCH_FLAGS_NON_BLOCKING, guard); 94 89 95 waitq_sleep_finish(&cv->wq, blocked, ipl);96 /* Lock only after releasing the waitq to avoid a possible deadlock. */97 90 mutex_lock(mtx); 98 99 91 return rc; 100 92 } … … 102 94 errno_t condvar_wait(condvar_t *cv, mutex_t *mtx) 103 95 { 104 errno_t rc; 105 ipl_t ipl; 106 bool blocked; 96 wait_guard_t guard = waitq_sleep_prepare(&cv->wq); 107 97 108 ipl = waitq_sleep_prepare(&cv->wq);109 98 /* Unlock only after the waitq is locked so we don't miss a wakeup. */ 110 99 mutex_unlock(mtx); 111 100 112 cv->wq.missed_wakeups = 0; /* Enforce blocking. */ 113 rc = waitq_sleep_unsafe(&cv->wq, &blocked); 114 assert(blocked || rc != EOK); 101 errno_t rc = waitq_sleep_unsafe(&cv->wq, guard); 115 102 116 waitq_sleep_finish(&cv->wq, blocked, ipl);117 /* Lock only after releasing the waitq to avoid a possible deadlock. */118 103 mutex_lock(mtx); 119 120 104 return rc; 121 105 } … … 142 126 uint32_t usec, int flags) 143 127 { 144 errno_t rc; 145 ipl_t ipl; 146 bool blocked; 147 148 ipl = waitq_sleep_prepare(&cv->wq); 128 wait_guard_t guard = waitq_sleep_prepare(&cv->wq); 149 129 150 130 /* Unlock only after the waitq is locked so we don't miss a wakeup. */ 151 131 spinlock_unlock(lock); 152 132 153 cv->wq.missed_wakeups = 0; /* Enforce blocking. */ 154 rc = waitq_sleep_timeout_unsafe(&cv->wq, usec, flags, &blocked); 155 assert(blocked || rc != EOK); 133 errno_t rc = waitq_sleep_timeout_unsafe(&cv->wq, usec, flags, guard); 156 134 157 waitq_sleep_finish(&cv->wq, blocked, ipl);158 /* Lock only after releasing the waitq to avoid a possible deadlock. */159 135 spinlock_lock(lock); 160 161 136 return rc; 162 137 }
Note:
See TracChangeset
for help on using the changeset viewer.