Changeset 116d1ef4 in mainline for generic/src/synch/waitq.c
- Timestamp:
- 2006-06-02T12:26:50Z (18 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- d0c5901
- Parents:
- 01ebbdf
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
generic/src/synch/waitq.c
r01ebbdf r116d1ef4 136 136 spinlock_lock(&t->lock); 137 137 if ((wq = t->sleep_queue)) { /* assignment */ 138 if (!(t->sleep_interruptible)) { 139 /* 140 * The sleep cannot be interrupted. 141 */ 142 spinlock_unlock(&t->lock); 143 goto out; 144 } 145 138 146 if (!spinlock_trylock(&wq->lock)) { 139 147 spinlock_unlock(&t->lock); … … 160 168 /** Sleep until either wakeup, timeout or interruption occurs 161 169 * 162 * This is a sleep implementation which allows itself to be170 * This is a sleep implementation which allows itself to time out or to be 163 171 * interrupted from the sleep, restoring a failover context. 164 172 * … … 170 178 * @param wq Pointer to wait queue. 171 179 * @param usec Timeout in microseconds. 172 * @param nonblocking Blocking vs. non-blocking operation mode switch. 173 * 174 * If usec is greater than zero, regardless of the value of nonblocking, 175 * the call will not return until either timeout or wakeup comes. 176 * 177 * If usec is zero and @nonblocking is zero (false), the call 178 * will not return until wakeup comes. 179 * 180 * If usec is zero and nonblocking is non-zero (true), the call will 180 * @param flags Specify mode of the sleep. 181 * 182 * The sleep can be interrupted only if the 183 * SYNCH_FLAGS_INTERRUPTIBLE bit is specified in flags. 184 185 * If usec is greater than zero, regardless of the value of the 186 * SYNCH_FLAGS_NON_BLOCKING bit in flags, the call will not return until either timeout, 187 * interruption or wakeup comes. 188 * 189 * If usec is zero and the SYNCH_FLAGS_NON_BLOCKING bit is not set in flags, the call 190 * will not return until wakeup or interruption comes. 191 * 192 * If usec is zero and the SYNCH_FLAGS_NON_BLOCKING bit is set in flags, the call will 181 193 * immediately return, reporting either success or failure. 182 194 * 183 * @return Returns one of: ESYNCH_WOULD_BLOCK, ESYNCH_TIMEOUT, 195 * @return Returns one of: ESYNCH_WOULD_BLOCK, ESYNCH_TIMEOUT, ESYNCH_INTERRUPTED, 184 196 * ESYNCH_OK_ATOMIC, ESYNCH_OK_BLOCKED. 185 197 * … … 198 210 * attempted. 199 211 */ 200 int waitq_sleep_timeout(waitq_t *wq, __u32 usec, int nonblocking)212 int waitq_sleep_timeout(waitq_t *wq, __u32 usec, int flags) 201 213 { 202 214 ipl_t ipl; … … 204 216 205 217 ipl = waitq_sleep_prepare(wq); 206 rc = waitq_sleep_timeout_unsafe(wq, usec, nonblocking);218 rc = waitq_sleep_timeout_unsafe(wq, usec, flags); 207 219 waitq_sleep_finish(wq, rc, ipl); 208 220 return rc; … … 277 289 * @param wq See waitq_sleep_timeout(). 278 290 * @param usec See waitq_sleep_timeout(). 279 * @param nonblockingSee waitq_sleep_timeout().291 * @param flags See waitq_sleep_timeout(). 280 292 * 281 293 * @return See waitq_sleep_timeout(). 282 294 */ 283 int waitq_sleep_timeout_unsafe(waitq_t *wq, __u32 usec, int nonblocking)295 int waitq_sleep_timeout_unsafe(waitq_t *wq, __u32 usec, int flags) 284 296 { 285 297 /* checks whether to go to sleep at all */ … … 289 301 } 290 302 else { 291 if ( nonblocking&& (usec == 0)) {303 if ((flags & SYNCH_FLAGS_NON_BLOCKING) && (usec == 0)) { 292 304 /* return immediatelly instead of going to sleep */ 293 305 return ESYNCH_WOULD_BLOCK; … … 300 312 spinlock_lock(&THREAD->lock); 301 313 302 /* 303 * Set context that will be restored if the sleep 304 * of this thread is ever interrupted. 305 */ 306 if (!context_save(&THREAD->sleep_interruption_context)) { 307 /* Short emulation of scheduler() return code. */ 308 spinlock_unlock(&THREAD->lock); 309 return ESYNCH_INTERRUPTED; 314 if (flags & SYNCH_FLAGS_INTERRUPTIBLE) { 315 /* 316 * Set context that will be restored if the sleep 317 * of this thread is ever interrupted. 318 */ 319 THREAD->sleep_interruptible = true; 320 if (!context_save(&THREAD->sleep_interruption_context)) { 321 /* Short emulation of scheduler() return code. */ 322 spinlock_unlock(&THREAD->lock); 323 return ESYNCH_INTERRUPTED; 324 } 325 } else { 326 THREAD->sleep_interruptible = false; 310 327 } 311 328
Note:
See TracChangeset
for help on using the changeset viewer.