Process scheduling is the activity of the process manager that handles the removal of the running process from the CPU and the selection of another process based on a particular strategy.

Process-Scheduler.png

Categories of Scheduling

Non-Preemptive: A process’ resource cannot be taken before the process has finished running.

Preemptive: The process switches from running state to ready state or from waiting state to ready state during resource allocation. This switching happens because the CPU may give other processes priority and substitute the currently active process for the higher priority process.

Types of Process Schedulers

Long Term or Job Scheduler

It brings the new process to the ‘Ready State’. It controls the Degree of Multi-programming, i.e., the number of processes present in a ready state at any point in time. It is important that the long-term scheduler make a careful selection of both I/O and CPU-bound processes. I/O-bound tasks are which use much of their time in input and output operations while CPU-bound processes are which spend their time on the CPU. The job scheduler increases efficiency by maintaining a balance between the two. They operate at a high level and are typically used in batch-processing systems.

Short Term or CPU Scheduler

It is responsible for selecting one process from the ready state for scheduling it on the running state.

<aside> 💡

Short-term scheduler only selects the process to schedule, it doesn’t load the process on running.

</aside>

Short-Term-Scheduler.png

The dispatcher is responsible for loading the process selected by the Short-term scheduler by context switching.

Medium Term Scheduler

It is responsible for suspending and resuming the process, mainly by swapping. Swapping may be necessary to improve the process mix or because a change in memory requirements has overcommitted available memory, requiring memory to be freed up. It is helpful in maintaining a perfect balance between the I/O bound and the CPU bound, by reducing the degree of Multi-programming.