Process Scheduler

Linux 2.6 kernel scheduler is O(1) scheduler . i.e. the time taken for the scheduler is constant, irrespective of the number of processes.

What does a scheduler do? It is responsible selecting a process to run. A scheduler might be a cooperative or preemptive. In cooperative, a process voluntarily gives up cpu after some period so that other processes can continue. In preemptive kernel, a process will be removed from running, after its time slice is completed. Linux is pre-emptive kernel.
A process will be either running, ready to run or sleeping on an event. If the proess is sleeping, when it wakes up, its priority is compared with the priority of running process. If it is greater, then this process will be made running.
Priority of a process, has two parts. Static priority which is also called nice value which has the range from -20 to 19 and dynamic priority. Higher the nice value, lower is the priority. Dynamic priority considers the interactiveness of the processes. So called interactive processes, do not hog the cpu time. They spend a lot of time sleeping on i/o events. These are encouraged with higher dynamic priorities. The processes which are cpu bound, will have lower priorities.
A process is runnable, as long as it is having its time slice. When its time slice is completed, it will become runnable only after all the other processes of same priority complete their time slices.

References : Scheduling from informit

Comments

Popular Posts