CPU_IDLE(9)

NAME
cpu_idle - idle CPU while waiting for work

SYNOPSIS
#include <sys/proc.h>
void
cpu_idle(void);

DESCRIPTION
The cpu_idle() function is invoked to idle the current CPU while waiting for work to be done. It is primarily called by the scheduler if no processes are available on the system run queue. The cpu_idle() function is a machine-dependent implementations in order to permit low-level CPU control.

The cpu_idle() function must be called with the scheduler lock held and at the splsched(9) interrupt protection level. It performs the following operations:

•   Release the scheduler lock.

•   Lower the current interrupt priority level to permit interrupts to be taken that will eventually cause processes to appear again on the system run queue.

•   Try to zero some pages for the virtual memory system.

•   Perform any CPU or system power control.

•   Wait until a process appears on the system run queue.

•   Acquire the scheduler lock.

For CPUs which don't support an idle operation, the CPU must spin until a process appears on the system run queue. Generally, this is done by checking if the sched_whichqs variable in the scheduler is not zero. See setrunqueue(9) for further details.

SEE ALSO
mi_switch(9), scheduler(9), setrunqueue(9), spl(9), uvm(9)