Rev 214 | Rev 241 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 214 | Rev 227 | ||
---|---|---|---|
Line 44... | Line 44... | ||
44 | #include <arch/faddr.h> |
44 | #include <arch/faddr.h> |
45 | #include <arch/atomic.h> |
45 | #include <arch/atomic.h> |
46 | #include <print.h> |
46 | #include <print.h> |
47 | #include <mm/frame.h> |
47 | #include <mm/frame.h> |
48 | #include <mm/heap.h> |
48 | #include <mm/heap.h> |
- | 49 | #include <debug.h> |
|
49 | 50 | ||
50 | - | ||
51 | volatile int nrdy; |
51 | volatile count_t nrdy; |
52 | 52 | ||
53 | 53 | ||
54 | /** Take actions before new thread runs |
54 | /** Take actions before new thread runs |
55 | * |
55 | * |
56 | * Perform actions that need to be |
56 | * Perform actions that need to be |
Line 88... | Line 88... | ||
88 | { |
88 | { |
89 | thread_t *t; |
89 | thread_t *t; |
90 | runq_t *r; |
90 | runq_t *r; |
91 | int i, n; |
91 | int i, n; |
92 | 92 | ||
- | 93 | ASSERT(CPU != NULL); |
|
- | 94 | ||
93 | loop: |
95 | loop: |
94 | cpu_priority_high(); |
96 | cpu_priority_high(); |
95 | 97 | ||
96 | spinlock_lock(&CPU->lock); |
98 | spinlock_lock(&CPU->lock); |
97 | n = CPU->nrdy; |
99 | n = CPU->nrdy; |
Line 145... | Line 147... | ||
145 | goto retry; |
147 | goto retry; |
146 | } |
148 | } |
147 | CPU->nrdy--; |
149 | CPU->nrdy--; |
148 | spinlock_unlock(&CPU->lock); |
150 | spinlock_unlock(&CPU->lock); |
149 | 151 | ||
150 | atomic_dec(&nrdy); |
152 | atomic_dec((int *) &nrdy); |
151 | r->n--; |
153 | r->n--; |
152 | 154 | ||
153 | /* |
155 | /* |
154 | * Take the first thread from the queue. |
156 | * Take the first thread from the queue. |
155 | */ |
157 | */ |
Line 227... | Line 229... | ||
227 | */ |
229 | */ |
228 | void scheduler(void) |
230 | void scheduler(void) |
229 | { |
231 | { |
230 | volatile pri_t pri; |
232 | volatile pri_t pri; |
231 | 233 | ||
- | 234 | ASSERT(CPU != NULL); |
|
- | 235 | ||
232 | pri = cpu_priority_high(); |
236 | pri = cpu_priority_high(); |
233 | 237 | ||
234 | if (haltstate) |
238 | if (haltstate) |
235 | halt(); |
239 | halt(); |
236 | 240 | ||
Line 290... | Line 294... | ||
290 | */ |
294 | */ |
291 | void scheduler_separated_stack(void) |
295 | void scheduler_separated_stack(void) |
292 | { |
296 | { |
293 | int priority; |
297 | int priority; |
294 | 298 | ||
- | 299 | ASSERT(CPU != NULL); |
|
- | 300 | ||
295 | if (THREAD) { |
301 | if (THREAD) { |
296 | switch (THREAD->state) { |
302 | switch (THREAD->state) { |
297 | case Running: |
303 | case Running: |
298 | THREAD->state = Ready; |
304 | THREAD->state = Ready; |
299 | spinlock_unlock(&THREAD->lock); |
305 | spinlock_unlock(&THREAD->lock); |