Rev 624 | Rev 689 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
| Rev 624 | Rev 625 | ||
|---|---|---|---|
| Line 93... | Line 93... | ||
| 93 | * |
93 | * |
| 94 | */ |
94 | */ |
| 95 | void thread_init(void) |
95 | void thread_init(void) |
| 96 | { |
96 | { |
| 97 | THREAD = NULL; |
97 | THREAD = NULL; |
| 98 | nrdy = 0; |
98 | atomic_set(&nrdy,0); |
| 99 | } |
99 | } |
| 100 | 100 | ||
| 101 | 101 | ||
| 102 | /** Make thread ready |
102 | /** Make thread ready |
| 103 | * |
103 | * |
| Line 109... | Line 109... | ||
| 109 | void thread_ready(thread_t *t) |
109 | void thread_ready(thread_t *t) |
| 110 | { |
110 | { |
| 111 | cpu_t *cpu; |
111 | cpu_t *cpu; |
| 112 | runq_t *r; |
112 | runq_t *r; |
| 113 | ipl_t ipl; |
113 | ipl_t ipl; |
| 114 | int i, avg, send_ipi = 0; |
114 | int i, avg; |
| 115 | 115 | ||
| 116 | ipl = interrupts_disable(); |
116 | ipl = interrupts_disable(); |
| 117 | 117 | ||
| 118 | spinlock_lock(&t->lock); |
118 | spinlock_lock(&t->lock); |
| 119 | 119 | ||
| Line 133... | Line 133... | ||
| 133 | list_append(&t->rq_link, &r->rq_head); |
133 | list_append(&t->rq_link, &r->rq_head); |
| 134 | r->n++; |
134 | r->n++; |
| 135 | spinlock_unlock(&r->lock); |
135 | spinlock_unlock(&r->lock); |
| 136 | 136 | ||
| 137 | atomic_inc(&nrdy); |
137 | atomic_inc(&nrdy); |
| 138 | avg = nrdy / config.cpu_active; |
138 | avg = atomic_get(&nrdy) / config.cpu_active; |
| 139 | 139 | ||
| 140 | spinlock_lock(&cpu->lock); |
140 | spinlock_lock(&cpu->lock); |
| 141 | if ((++cpu->nrdy) > avg) { |
141 | if ((++cpu->nrdy) > avg) { |
| 142 | /* |
142 | /* |
| 143 | * If there are idle halted CPU's, this will wake them up. |
143 | * If there are idle halted CPU's, this will wake them up. |