Process Scheduling handles the selection of a process for the processor on the basis of a scheduling algorithm and also the removal of a process from the processor. It is an important part of multiprogramming in operating system.
Process scheduling algorithms are used to handle the selection of a process for the processor or distribute resources maong processes.
Some of the process scheduling algorithms are given as follows −
This algorithm handles the processes in the order they arrive in the ready queue. FCFS is the simplest scheduling algorithm. There is no preemption in FCFS and so no starvation occurs. Still, its throughput is quite low because large processes may hold the CPU for a long time.
This algorithm executes processes in order of their execution times i.e the process with the smallest execution time is selected first. SJF supports preemption and so can lead to starvation for some processes. However, it provides the maximum throughput in most cases.
This algorithm executes processes in order of their priority, which is specified for each process. Lower priority processes may be preempted by higher priority processes and this can lead to starvation for some processes.
This algorithm provides a fixed time slice for each process and cycles through all the processes until their execution is complete. There is no starvation possible since each process gets the chance to execute. If the time slice is too large then Round Robin algorithm behaves like FIFO and if it is too small, it behaves like SJF.
Process scheduling involves short-term schedulers, medium-term schedulers and long-term schedulers. Details about these are given as follows −
Long-term schedulers perform long-term scheduling. This involves selecting the processes from the storage pool in the secondary memory and loading them into the ready queue in the main memory for execution.
The long-term scheduler controls the degree of multiprogramming. It must select a careful mixture of I/O bound and CPU bound processes to yield optimum system throughput. If it selects too many CPU bound processes then the I/O devices are idle and if it selects too many I/O bound processes then the processor has nothing to do.
Short-term schedulers perform short-term scheduling. This involves selecting one of the processes from the ready queue and scheduling them for execution. A scheduling algorithm is used to decide which process will be scheduled for execution next by the short-term scheduler.
A diagram that demonstrates scheduling using long-term and short-term schedulers is given as follows −
Medium-term schedulers perform medium-term scheduling. This involves swapping out a process from main memory. The process can be swapped in later from the point it stopped executing.
This can also be called as suspending and resuming the process and is helpful in reducing the degree of multiprogramming. Swapping is also useful to improve the mix of I/O bound and CPU bound processes in the memory.
A diagram that demonstrates medium-term scheduling is given as follows −