Reputation: 33036
When the cpu isn't doing anything, it runs the idle process. I heard that this process looks for programs that are waiting in the queue so that the cpu can run them. Is that all it does? What does the code for it look like? I am also interested in knowing the file name of the system idle process in the various OSes.
Upvotes: 10
Views: 8065
Reputation: 57
The idle process is for scheduler to run something when no process is executing. It depends on the OS particularly.
For simple understanding we can say idle process is a infinite loop, which will get scheduled when no process is running
Upvotes: 0
Reputation: 2192
The question contains several erroneous tacit assumptions. Here are some pointers:
hlt
instruction, the intent of which is in general terms to reduce the idling processor's use of the system bus (so that, of course, non-idle processors can use that bus bandwidth). So on many architectures the infinite loop repeatedly executes those instructions. Some processors can signal their "idle" state on the bus when they execute such instructions, which external hardware can recognize and act upon (such as by slowing bus clocks down and consuming less power, for example). Similarly, the idle instructions can cause the processors themselves to do things like clock-slowing and power-saving.Upvotes: 13
Reputation: 90027
The Idle process doesn't do anything; the OS itself is responsible for scheduling processes to run. The Idle process itself just loops HLT instructions. (source: wikipedia )
Upvotes: 5
Reputation: 67879
In space critical embedded systems, the idle process is used to scrub memory in order to check whether cosmic rays have introduced bit flips.
Upvotes: 7
Reputation: 25436
The OS runs the scheduler whenever a process is at the end of its time slice, and whenever a process has performed a blocking operation. The scheduler then picks the next process to run. On the platforms I know, it does not make sense to see the scheduler as a process.
Here is a little more about scheduling.
Upvotes: 2