41 |
??? should we use continuations? */ |
??? should we use continuations? */ |
42 |
static void idle_thread_fn (void *arg) |
static void idle_thread_fn (void *arg) |
43 |
{ |
{ |
44 |
|
struct processor *processor = PROCESSOR_CURRENT (); |
45 |
trace_printf ("starting idle thread for CPU %d", CPU_CURRENT ()); |
trace_printf ("starting idle thread for CPU %d", CPU_CURRENT ()); |
46 |
|
|
47 |
for (;;) |
for (;;) |
48 |
; |
{ |
49 |
|
while (processor->state == PROCESSOR_STATE_IDLE) |
50 |
|
; /* ??? machine halt insn or such thing. */ |
51 |
|
|
52 |
|
/* When we break into this we should have a thread in the NEXT_THREAD |
53 |
|
field of our processor structure. */ |
54 |
|
|
55 |
|
ASSERT (processor->next_thread); |
56 |
|
} |
57 |
} |
} |
58 |
|
|
59 |
/* Initailize all idle threads. */ |
/* Initailize all idle threads. */ |
84 |
/* Set idle bit in scheduling state and hardwire the priority |
/* Set idle bit in scheduling state and hardwire the priority |
85 |
to zero. Bind the thread to PROCESSOR and start the thread. */ |
to zero. Bind the thread to PROCESSOR and start the thread. */ |
86 |
|
|
87 |
|
thread->scratch_area[3] = 666; |
88 |
|
|
89 |
thread->sched_state |= THREAD_STATE_IDLE; |
thread->sched_state |= THREAD_STATE_IDLE; |
90 |
thread->sched_priority = 0; |
thread_set_priority (thread, THREAD_POLICY_TIMESHARE, 0); |
|
thread_bind (thread, processor); |
|
91 |
thread_start (thread, idle_thread_fn, processor); |
thread_start (thread, idle_thread_fn, processor); |
|
thread_setrun (thread, false); |
|
92 |
} |
} |
93 |
} |
} |
94 |
|
|