Rev 11 | Rev 107 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 11 | Rev 15 | ||
---|---|---|---|
Line 55... | Line 55... | ||
55 | 55 | ||
56 | /* |
56 | /* |
57 | * To avoid lock ordering problems, |
57 | * To avoid lock ordering problems, |
58 | * run all expired timeouts as you visit them. |
58 | * run all expired timeouts as you visit them. |
59 | */ |
59 | */ |
60 | spinlock_lock(&the->cpu->timeoutlock); |
60 | spinlock_lock(&CPU->timeoutlock); |
61 | while ((l = the->cpu->timeout_active_head.next) != &the->cpu->timeout_active_head) { |
61 | while ((l = CPU->timeout_active_head.next) != &CPU->timeout_active_head) { |
62 | h = list_get_instance(l, timeout_t, link); |
62 | h = list_get_instance(l, timeout_t, link); |
63 | spinlock_lock(&h->lock); |
63 | spinlock_lock(&h->lock); |
64 | if (h->ticks-- != 0) { |
64 | if (h->ticks-- != 0) { |
65 | spinlock_unlock(&h->lock); |
65 | spinlock_unlock(&h->lock); |
66 | break; |
66 | break; |
Line 68... | Line 68... | ||
68 | list_remove(l); |
68 | list_remove(l); |
69 | f = h->handler; |
69 | f = h->handler; |
70 | arg = h->arg; |
70 | arg = h->arg; |
71 | timeout_reinitialize(h); |
71 | timeout_reinitialize(h); |
72 | spinlock_unlock(&h->lock); |
72 | spinlock_unlock(&h->lock); |
73 | spinlock_unlock(&the->cpu->timeoutlock); |
73 | spinlock_unlock(&CPU->timeoutlock); |
74 | 74 | ||
75 | f(arg); |
75 | f(arg); |
76 | 76 | ||
77 | spinlock_lock(&the->cpu->timeoutlock); |
77 | spinlock_lock(&CPU->timeoutlock); |
78 | } |
78 | } |
79 | spinlock_unlock(&the->cpu->timeoutlock); |
79 | spinlock_unlock(&CPU->timeoutlock); |
80 | 80 | ||
81 | /* |
81 | /* |
82 | * Do CPU usage accounting and find out whether to preempt the->thread. |
82 | * Do CPU usage accounting and find out whether to preempt THREAD. |
83 | */ |
83 | */ |
84 | 84 | ||
85 | if (the->thread) { |
85 | if (THREAD) { |
86 | spinlock_lock(&the->cpu->lock); |
86 | spinlock_lock(&CPU->lock); |
87 | the->cpu->needs_relink++; |
87 | CPU->needs_relink++; |
88 | spinlock_unlock(&the->cpu->lock); |
88 | spinlock_unlock(&CPU->lock); |
89 | 89 | ||
90 | spinlock_lock(&the->thread->lock); |
90 | spinlock_lock(&THREAD->lock); |
91 | if (!the->thread->ticks--) { |
91 | if (!THREAD->ticks--) { |
92 | spinlock_unlock(&the->thread->lock); |
92 | spinlock_unlock(&THREAD->lock); |
93 | scheduler(); |
93 | scheduler(); |
94 | } |
94 | } |
95 | else { |
95 | else { |
96 | spinlock_unlock(&the->thread->lock); |
96 | spinlock_unlock(&THREAD->lock); |
97 | } |
97 | } |
98 | } |
98 | } |
99 | 99 | ||
100 | } |
100 | } |