Rev 1593 | Rev 1702 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
| Rev 1593 | Rev 1681 | ||
|---|---|---|---|
| Line 97... | Line 97... | ||
| 97 | } |
97 | } |
| 98 | 98 | ||
| 99 | list_remove(&t->wq_link); |
99 | list_remove(&t->wq_link); |
| 100 | t->saved_context = t->sleep_timeout_context; |
100 | t->saved_context = t->sleep_timeout_context; |
| 101 | do_wakeup = true; |
101 | do_wakeup = true; |
| 102 | - | ||
| 103 | spinlock_unlock(&wq->lock); |
- | |
| 104 | t->sleep_queue = NULL; |
102 | t->sleep_queue = NULL; |
| - | 103 | spinlock_unlock(&wq->lock); |
|
| 105 | } |
104 | } |
| 106 | 105 | ||
| 107 | t->timeout_pending = false; |
106 | t->timeout_pending = false; |
| 108 | spinlock_unlock(&t->lock); |
107 | spinlock_unlock(&t->lock); |
| 109 | 108 | ||
| Line 152... | Line 151... | ||
| 152 | t->timeout_pending = false; |
151 | t->timeout_pending = false; |
| 153 | 152 | ||
| 154 | list_remove(&t->wq_link); |
153 | list_remove(&t->wq_link); |
| 155 | t->saved_context = t->sleep_interruption_context; |
154 | t->saved_context = t->sleep_interruption_context; |
| 156 | do_wakeup = true; |
155 | do_wakeup = true; |
| 157 | - | ||
| 158 | spinlock_unlock(&wq->lock); |
- | |
| 159 | t->sleep_queue = NULL; |
156 | t->sleep_queue = NULL; |
| - | 157 | spinlock_unlock(&wq->lock); |
|
| 160 | } |
158 | } |
| 161 | spinlock_unlock(&t->lock); |
159 | spinlock_unlock(&t->lock); |
| 162 | 160 | ||
| 163 | if (do_wakeup) |
161 | if (do_wakeup) |
| 164 | thread_ready(t); |
162 | thread_ready(t); |
| Line 416... | Line 414... | ||
| 416 | return; |
414 | return; |
| 417 | } |
415 | } |
| 418 | 416 | ||
| 419 | t = list_get_instance(wq->head.next, thread_t, wq_link); |
417 | t = list_get_instance(wq->head.next, thread_t, wq_link); |
| 420 | 418 | ||
| - | 419 | /* |
|
| - | 420 | * Lock the thread prior to removing it from the wq. |
|
| - | 421 | * This is not necessary because of mutual exclusion |
|
| - | 422 | * (the link belongs to the wait queue), but because |
|
| - | 423 | * of synchronization with waitq_timeouted_sleep() |
|
| - | 424 | * and waitq_interrupt_sleep(). |
|
| - | 425 | * |
|
| - | 426 | * In order for these two functions to work, the following |
|
| - | 427 | * invariant must hold: |
|
| - | 428 | * |
|
| - | 429 | * t->sleep_queue != NULL <=> t sleeps in a wait queue |
|
| - | 430 | * |
|
| - | 431 | * For an observer who locks the thread, the invariant |
|
| - | 432 | * holds only when the lock is held prior to removing |
|
| 421 | list_remove(&t->wq_link); |
433 | * it from the wait queue. |
| - | 434 | */ |
|
| 422 | spinlock_lock(&t->lock); |
435 | spinlock_lock(&t->lock); |
| - | 436 | list_remove(&t->wq_link); |
|
| - | 437 | ||
| 423 | if (t->timeout_pending && timeout_unregister(&t->sleep_timeout)) |
438 | if (t->timeout_pending && timeout_unregister(&t->sleep_timeout)) |
| 424 | t->timeout_pending = false; |
439 | t->timeout_pending = false; |
| 425 | t->sleep_queue = NULL; |
440 | t->sleep_queue = NULL; |
| 426 | spinlock_unlock(&t->lock); |
441 | spinlock_unlock(&t->lock); |
| 427 | 442 | ||