CPU Schedulers And Its Types

CPU Schedulers are also known as CPU Dispatchers. It is a module or program that provides control of the CPU to the process. The Dispatcher executes each context switching. Dispatch latency is the time that is needed by the CPU scheduler to stop one process and start another.

The operating system uses various CPU schedulers. Let’s explain with a diagram,

1. Long term scheduler

The long-term scheduler is also known as a job scheduler. It chooses the processes from secondary memory and puts them in the ready queue in the main memory.

It handles the degree of Multi-programming. The main purpose of a long-term scheduler is to select a perfect mix of CPU-bound and IO-bound processes among the various processes present in the secondary memory.

If the job scheduler selects more IO-bound processes, then all of the jobs may reside in the block state (due to I/O request). So, all that time, the CPU will sit idle. This will decrease the degree of Multi programming. Therefore, the long-term scheduler job is very important.

2. Short term scheduler

The short-term scheduler is also known as the CPU scheduler. OS uses a short-term scheduler to select one of the processes from the ready queue and dispatch it to the CPU for execution.

Short-term schedulers use a scheduling algorithm to select a process from the ready queue.

Starvation problems may occur if the short-term scheduler makes some mistakes while choosing the process, such as selecting a process that has a very high burst time.

3. Medium term scheduler

It involves swapping out and switching between the main memory and secondary memory.

It suspends the process and transfers it toward secondary memory from main memory and resumes the suspended process from secondary memory to primary memory.

So, in the short and medium term, the scheduler is responsible for suspending the process from main memory to secondary memory and resuming the processes from secondary to main memory.