FreeBSD/sys/kern/kern_idle.c
/*
 * 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.
 */
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.
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 .
static void
idle_setup(void *dummy)
{
#ifdef SMP
	struct pcpu *pc;
#endif
	struct proc *p;
	struct thread *td;
	int error;
	p = NULL; 
#ifdef SMP
	STAILQ_FOREACH(pc, &cpuhead, pc_allcpu) {
#endif
#ifdef SMP
		error = kproc_kthread_add(sched_idletd, NULL, &p, &td,
		    RFSTOPPED | RFHIGHPID, 0, "idle", "idle: cpu%d", pc->pc_cpuid);
		pc->pc_idlethread = td;
#else
		error = kproc_kthread_add(sched_idletd, NULL, &p, &td,
		    RFSTOPPED | RFHIGHPID, 0, "idle", "idle");
		PCPU_SET(idlethread, td);
#endif
		if (error)
			panic("idle_setup: kproc_create error %d\n", error);
		thread_lock(td);
		TD_SET_CAN_RUN(td);
		td->td_flags |= TDF_IDLETD | TDF_NOLOAD;
		sched_class(td, PRI_IDLE);
		sched_prio(td, PRI_MAX_IDLE);
		thread_unlock(td);
#ifdef SMP
	}
#endif
}
static void idle_setup ( void * dummy ) { #ifdef SMP struct pcpu * pc ; #endif struct proc * p ; struct thread * td ; int error ; p = NULL ; #ifdef SMP STAILQ_FOREACH ( pc , & cpuhead , pc_allcpu ) { #endif #ifdef SMP error = kproc_kthread_add ( sched_idletd , NULL , & p , & td , RFSTOPPED | RFHIGHPID , 0 , " " , " " , pc -> pc_cpuid ) ; pc -> pc_idlethread = td ; #else error = kproc_kthread_add ( sched_idletd , NULL , & p , & td , RFSTOPPED | RFHIGHPID , 0 , " " , " " ) ; PCPU_SET ( idlethread , td ) ; #endif if ( error ) panic ( " \n " , error ) ; thread_lock ( td ) ; TD_SET_CAN_RUN ( td ) ; td -> td_flags |= TDF_IDLETD | TDF_NOLOAD ; sched_class ( td , PRI_IDLE ) ; sched_prio ( td , PRI_MAX_IDLE ) ; thread_unlock ( td ) ; #ifdef SMP } #endif }
Set up per-cpu idle process contexts.
Set up per - cpu idle process contexts .
/* start with no idle process */