Rev 1264 | Rev 1433 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
| Rev 1264 | Rev 1431 | ||
|---|---|---|---|
| Line 60... | Line 60... | ||
| 60 | { |
60 | { |
| 61 | link_t *l; |
61 | link_t *l; |
| 62 | timeout_t *h; |
62 | timeout_t *h; |
| 63 | timeout_handler_t f; |
63 | timeout_handler_t f; |
| 64 | void *arg; |
64 | void *arg; |
| - | 65 | int i; |
|
| 65 | 66 | ||
| 66 | /* |
67 | /* |
| 67 | * To avoid lock ordering problems, |
68 | * To avoid lock ordering problems, |
| 68 | * run all expired timeouts as you visit them. |
69 | * run all expired timeouts as you visit them. |
| 69 | */ |
70 | */ |
| - | 71 | for (i = 0; i < CPU->missed_clock_ticks; i++) { |
|
| 70 | spinlock_lock(&CPU->timeoutlock); |
72 | spinlock_lock(&CPU->timeoutlock); |
| 71 | while ((l = CPU->timeout_active_head.next) != &CPU->timeout_active_head) { |
73 | while ((l = CPU->timeout_active_head.next) != &CPU->timeout_active_head) { |
| 72 | h = list_get_instance(l, timeout_t, link); |
74 | h = list_get_instance(l, timeout_t, link); |
| 73 | spinlock_lock(&h->lock); |
75 | spinlock_lock(&h->lock); |
| 74 | if (h->ticks-- != 0) { |
76 | if (h->ticks-- != 0) { |
| 75 | spinlock_unlock(&h->lock); |
77 | spinlock_unlock(&h->lock); |
| 76 | break; |
78 | break; |
| 77 | } |
79 | } |
| 78 | list_remove(l); |
80 | list_remove(l); |
| 79 | f = h->handler; |
81 | f = h->handler; |
| 80 | arg = h->arg; |
82 | arg = h->arg; |
| 81 | timeout_reinitialize(h); |
83 | timeout_reinitialize(h); |
| 82 | spinlock_unlock(&h->lock); |
84 | spinlock_unlock(&h->lock); |
| 83 | spinlock_unlock(&CPU->timeoutlock); |
85 | spinlock_unlock(&CPU->timeoutlock); |
| 84 | 86 | ||
| 85 | f(arg); |
87 | f(arg); |
| 86 | 88 | ||
| 87 | spinlock_lock(&CPU->timeoutlock); |
89 | spinlock_lock(&CPU->timeoutlock); |
| - | 90 | } |
|
| - | 91 | spinlock_unlock(&CPU->timeoutlock); |
|
| 88 | } |
92 | } |
| 89 | spinlock_unlock(&CPU->timeoutlock); |
93 | CPU->missed_clock_ticks = 0; |
| 90 | 94 | ||
| 91 | /* |
95 | /* |
| 92 | * Do CPU usage accounting and find out whether to preempt THREAD. |
96 | * Do CPU usage accounting and find out whether to preempt THREAD. |
| 93 | */ |
97 | */ |
| 94 | 98 | ||