What are process schedulers in operating systems?
Overview
The scheduling of the process is essential due to multi-programming in the operating systems. Modern OSs allow us to load more than one process into the main memory and share the CPU, which increases CPU utilization and reduces the program response time. But we need some mechanism to schedule these processes for execution.
Process scheduling
Process scheduling is the process management activity that removes running processes from the CPU and selects new processes based on different strategies from the
In this answer, we'll discuss different process schedulers.
Types of process schedulers
There are three types of process schedulers in operating systems based on their features:
- Long Term or job scheduler
- Short-term or CPU scheduler
- Medium-term scheduler
Before discussing the schedulers, it's important to learn about the two-state model whose terminologies will be used later:
- Running state: When any new process is created, it enters the system as in the running state.
- Not Running state: Processes not running are kept in the queue, waiting for their turn to execute. A process is transferred to the waiting queue whenever it gets interrupted. The dispatcher selects a process to run if the process is completed or abandoned.
Long-term or job scheduler
The long-term or job scheduler controls the degree of multi-programming and the number of processes in a ready state at any time. This scheduler brings the new processes from the process queue to the ready state.
Note: Long-term scheduler carefully selects both
and I/O I/O bound tasks use much of their time in input and output operations. . CPU-bound processes CPU bound processes spend their time on CPU.
This scheduler increases the efficiency of CPU utilization since it maintains a balance between I/O and CPU-bound processes.
Short-term or CPU scheduler
The short-term or CPU scheduler is responsible for selecting a process from the ready state maintained by the job scheduler (long-term) for scheduling it on the running state. And this is where all the scheduling algorithms are used.
Note: This scheduler's job is to select the process only and not to load the process.
A short-term scheduler ensures that there's no starvation due to owing to high burst time processes.
Dispatcher
The dispatcher is responsible for loading these selected processes on the CPU. It sends the ready queue's process to the running state. A dispatcher can do context switching and switch to user mode as well.
Medium-term scheduler
The medium-term scheduler type is responsible for suspending and resuming the process. It is a part of the swapping process that enables us to handle the swapped out-processes. In a medium-term scheduler, a running process can become suspended, which makes an I/O request.
Note: Medium-term scheduler mainly moves processes from main memory to disk and vice versa.
This scheduler increases the balance between I/O and CPU-bound processes.
Comparison Between Schedulers
Short Term | Medium Term | Long Term |
It is a CPU scheduler because it selects the process to load next. | It is a process swapping scheduler, as it can change the process state. | It is a job scheduler because it maintains the number of jobs to execute at a time. |
It provides less control over the degree of multiprogramming. | It reduces the degree of multiprogramming. | It controls the degree of multiprogramming. |
Short term scheduler selects those processes which are ready to execute. | Medium term scheduler can re-introduce the process into memory, and execution can be continued. | Long term scheduler selects processes from the pool of available processes and loads them into memory for execution. |
Free Resources