linux-kernelidle-processing

linux kernel idle tick eater (or what will be current task_struct when CPU is 0%)


What process will be pointed by "current" pointer in linux kernel, when CPU load is 0% and there isn't any ready-to-run process?

Consider situation without any power-saving. What is the name of this process? I think task with PID 0 will be running and code will be

rep nop

or

HLT

Solution

  • Current will be pid 0, process swapper or the last process, which called blocking syscall?

    http://oreilly.com/catalog/linuxkernel/chapter/ch10.html

    Notice that if the runqueue list is empty (no runnable process exists except for swapper), the cycle is not entered and next points to init_task. Moreover, if all processes in the runqueue list have a priority lesser than or equal to the priority of prev, no process switch will take place and the old process will continue to be executed.