Rev 1 | Rev 8 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 1 | Rev 7 | ||
---|---|---|---|
Line 43... | Line 43... | ||
43 | #include <context.h> |
43 | #include <context.h> |
44 | #include <list.h> |
44 | #include <list.h> |
45 | #include <typedefs.h> |
45 | #include <typedefs.h> |
46 | #include <time/clock.h> |
46 | #include <time/clock.h> |
47 | #include <list.h> |
47 | #include <list.h> |
- | 48 | #include <config.h> |
|
- | 49 | ||
- | 50 | #ifdef __SMP__ |
|
- | 51 | #include <arch/interrupt.h> |
|
- | 52 | #include <arch/apic.h> |
|
- | 53 | #endif /* __SMP__ */ |
|
48 | 54 | ||
49 | char *thread_states[] = {"Invalid", "Running", "Sleeping", "Ready", "Entering", "Exiting"}; |
55 | char *thread_states[] = {"Invalid", "Running", "Sleeping", "Ready", "Entering", "Exiting"}; |
50 | 56 | ||
51 | spinlock_t threads_lock; |
57 | spinlock_t threads_lock; |
52 | link_t threads_head; |
58 | link_t threads_head; |
Line 86... | Line 92... | ||
86 | void thread_ready(thread_t *t) |
92 | void thread_ready(thread_t *t) |
87 | { |
93 | { |
88 | cpu_t *cpu; |
94 | cpu_t *cpu; |
89 | runq_t *r; |
95 | runq_t *r; |
90 | pri_t pri; |
96 | pri_t pri; |
91 | int i; |
97 | int i, avg, send_ipi = 0; |
92 | 98 | ||
93 | pri = cpu_priority_high(); |
99 | pri = cpu_priority_high(); |
94 | 100 | ||
95 | spinlock_lock(&t->lock); |
101 | spinlock_lock(&t->lock); |
96 | 102 | ||
Line 110... | Line 116... | ||
110 | list_append(&t->rq_link, &r->rq_head); |
116 | list_append(&t->rq_link, &r->rq_head); |
111 | r->n++; |
117 | r->n++; |
112 | spinlock_unlock(&r->lock); |
118 | spinlock_unlock(&r->lock); |
113 | 119 | ||
114 | spinlock_lock(&nrdylock); |
120 | spinlock_lock(&nrdylock); |
115 | nrdy++; |
121 | avg = ++nrdy / config.cpu_active; |
116 | spinlock_unlock(&nrdylock); |
122 | spinlock_unlock(&nrdylock); |
117 | 123 | ||
118 | spinlock_lock(&cpu->lock); |
124 | spinlock_lock(&cpu->lock); |
- | 125 | if ((++cpu->nrdy) > avg && (config.cpu_active == config.cpu_count)) { |
|
- | 126 | /* |
|
- | 127 | * If there are idle halted CPU's, this will wake them up. |
|
- | 128 | */ |
|
119 | cpu->nrdy++; |
129 | #ifdef __SMP__ |
- | 130 | l_apic_broadcast_custom_ipi(VECTOR_WAKEUP_IPI); |
|
- | 131 | #endif /* __SMP__ */ |
|
- | 132 | } |
|
120 | spinlock_unlock(&cpu->lock); |
133 | spinlock_unlock(&cpu->lock); |
121 | 134 | ||
122 | cpu_priority_restore(pri); |
135 | cpu_priority_restore(pri); |
123 | } |
136 | } |
124 | 137 |