Changeset 5c8ba05 in mainline
- Timestamp:
- 2007-05-07T18:52:24Z (18 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 6fa4888b
- Parents:
- 4f42d52
- Location:
- kernel/generic
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/generic/include/synch/waitq.h
r4f42d52 r5c8ba05 41 41 #include <adt/list.h> 42 42 43 #define WAKEUP_FIRST 0 44 #define WAKEUP_ALL 1 43 typedef enum { 44 WAKEUP_FIRST = 0, 45 WAKEUP_ALL 46 } wakeup_mode_t; 45 47 46 48 /** Wait queue structure. */ … … 71 73 extern int waitq_sleep_timeout_unsafe(waitq_t *wq, uint32_t usec, int flags); 72 74 extern void waitq_sleep_finish(waitq_t *wq, int rc, ipl_t ipl); 73 extern void waitq_wakeup(waitq_t *wq, bool all);74 extern void _waitq_wakeup_unsafe(waitq_t *wq, bool all);75 extern void waitq_wakeup(waitq_t *wq, wakeup_mode_t mode); 76 extern void _waitq_wakeup_unsafe(waitq_t *wq, wakeup_mode_t mode); 75 77 extern void waitq_interrupt_sleep(struct thread *t); 76 78 -
kernel/generic/src/ipc/ipc.c
r4f42d52 r5c8ba05 164 164 list_append(&call->link, &callerbox->answers); 165 165 spinlock_unlock(&callerbox->lock); 166 waitq_wakeup(&callerbox->wq, 0);166 waitq_wakeup(&callerbox->wq, WAKEUP_FIRST); 167 167 } 168 168 … … 206 206 list_append(&call->link, &box->calls); 207 207 spinlock_unlock(&box->lock); 208 waitq_wakeup(&box->wq, 0);208 waitq_wakeup(&box->wq, WAKEUP_FIRST); 209 209 } 210 210 -
kernel/generic/src/proc/scheduler.c
r4f42d52 r5c8ba05 412 412 goto repeat; 413 413 } 414 _waitq_wakeup_unsafe(&THREAD->join_wq, false); 414 _waitq_wakeup_unsafe(&THREAD->join_wq, 415 WAKEUP_FIRST); 415 416 spinlock_unlock(&THREAD->join_wq.lock); 416 417 -
kernel/generic/src/synch/waitq.c
r4f42d52 r5c8ba05 384 384 * timeout. 385 385 * 386 * @param wq Pointer to wait queue. 387 * @param all If this is non-zero, all sleeping threads will be woken up and 388 * missed count will be zeroed. 389 */ 390 void waitq_wakeup(waitq_t *wq, bool all) 386 * @param wq Pointer to wait queue. 387 * @param mode Wakeup mode. 388 */ 389 void waitq_wakeup(waitq_t *wq, wakeup_mode_t mode) 391 390 { 392 391 ipl_t ipl; … … 395 394 spinlock_lock(&wq->lock); 396 395 397 _waitq_wakeup_unsafe(wq, all);398 399 spinlock_unlock(&wq->lock); 400 interrupts_restore(ipl); 396 _waitq_wakeup_unsafe(wq, mode); 397 398 spinlock_unlock(&wq->lock); 399 interrupts_restore(ipl); 401 400 } 402 401 … … 406 405 * assumes wq->lock is already locked and interrupts are already disabled. 407 406 * 408 * @param wq Pointer to wait queue. 409 * @param all If this is non-zero, all sleeping threads will be woken up and 410 * missed count will be zeroed. 411 */ 412 void _waitq_wakeup_unsafe(waitq_t *wq, bool all) 407 * @param wq Pointer to wait queue. 408 * @param mode If mode is WAKEUP_FIRST, then the longest waiting thread, 409 * if any, is woken up. If mode is WAKEUP_ALL, then all 410 * waiting threads, if any, are woken up. If there are no 411 * waiting threads to be woken up, the missed wakeup is 412 * recorded in the wait queue. 413 */ 414 void _waitq_wakeup_unsafe(waitq_t *wq, wakeup_mode_t mode) 413 415 { 414 416 thread_t *t; 417 count_t count = 0; 415 418 416 419 loop: 417 420 if (list_empty(&wq->head)) { 418 421 wq->missed_wakeups++; 419 if ( all)420 wq->missed_wakeups = 0;422 if (count && mode == WAKEUP_ALL) 423 wq->missed_wakeups--; 421 424 return; 422 425 } 423 426 427 count++; 424 428 t = list_get_instance(wq->head.next, thread_t, wq_link); 425 429 … … 450 454 thread_ready(t); 451 455 452 if ( all)456 if (mode == WAKEUP_ALL) 453 457 goto loop; 454 458 }
Note:
See TracChangeset
for help on using the changeset viewer.