* Set up per-cpu idle process contexts. The AP's shouldn't be running or * accessing their idle processes at this point, so don't bother with * locking. */
| 51 | * locking. |
| 52 | */ |
| 53 | static void |
| 54 | idle_setup(void *dummy) |
| 55 | { |
| 56 | #ifdef SMP |
| 57 | struct pcpu *pc; |
| 58 | #endif |
| 59 | struct proc *p; |
| 60 | struct thread *td; |
| 61 | int error; |
| 62 | |
| 63 | p = NULL; /* start with no idle process */ |
| 64 | #ifdef SMP |
| 65 | STAILQ_FOREACH(pc, &cpuhead, pc_allcpu) { |
| 66 | #endif |
| 67 | #ifdef SMP |
| 68 | error = kproc_kthread_add(sched_idletd, NULL, &p, &td, |
| 69 | RFSTOPPED | RFHIGHPID, 0, "idle", "idle: cpu%d", pc->pc_cpuid); |
| 70 | pc->pc_idlethread = td; |
| 71 | #else |
| 72 | error = kproc_kthread_add(sched_idletd, NULL, &p, &td, |
| 73 | RFSTOPPED | RFHIGHPID, 0, "idle", "idle"); |
| 74 | PCPU_SET(idlethread, td); |
| 75 | #endif |
| 76 | if (error) |
| 77 | panic("idle_setup: kproc_create error %d\n", error); |
| 78 | |
| 79 | thread_lock(td); |
| 80 | TD_SET_CAN_RUN(td); |
| 81 | td->td_flags |= TDF_IDLETD | TDF_NOLOAD; |
| 82 | sched_class(td, PRI_IDLE); |
| 83 | sched_prio(td, PRI_MAX_IDLE); |
| 84 | thread_unlock(td); |
| 85 | #ifdef SMP |
| 86 | } |
| 87 | #endif |
| 88 | } |
nothing calls this directly
no test coverage detected