Preemptive Vs. Non-Preemptive Scheduling

In this tutorial, we will learn about the preemptive, non-preemptive scheduling, and the difference between preemptive and non-preemptive scheduling. By Monika Jha Last updated : May 08, 2023

When the CPU is in the idle state, the CPU scheduler chooses a process from the ready queue and allocates the process to CPU. There are two types of scheduling,

  1. Preemptive Scheduling
  2. Non-Preemptive Scheduling

What is Preemptive Scheduling?

Once a process started its execution, scheduling occurs at the time of a process switches from running state to ready state and from waiting state to ready state is called Preemptive Scheduling.

In this scheduling resources (CPU cycles) are allocated to the process for a short period of time and if some process of higher priority is encountered then the current process can be paused to handle that process.

  • Then resources from the currently running process taken away, and the currently running process is placed back in the ready queue again if it still has remaining CPU burst time. That is we can preempt the control of CPU from one process to another if required. The process remains in a ready queue till it gets the next time slot to get executed.
  • By implementing this type of scheduling user can work on multiple processes that are it supports multitasking.
  • Examples of Preemptive Scheduling are Round Robin (RR), Shortest Remaining Time First (SRTF), Priority (preemptive version), etc.

What is Non-Preemptive Scheduling?

Once a process started its execution, scheduling occurs when a process terminates, or a process switches from running to waiting state.

  • When the resources (CPU) are allocated to a process, the process holds the CPU till it gets terminated or it reaches a waiting state.
  • In non-preemptive scheduling, the scheduler does not interrupt a currently running process in the middle of the execution. But it waits for the process to complete its execution with the CPU, after that it can allocate the CPU to another process.
  • FCFS scheduling is an example of non-preemptive scheduling.

Difference Between Preemptive and Non-Preemptive Scheduling

The following are the key difference between preemptive and non-preemptive scheduling:

  1. In the middle of the execution of a process the execution is interrupted whereas; in non-preemptive scheduling, execution is not interrupted in the middle of execution.
  2. Preemptive Scheduling suffers from the overhead of switching between processes from the ready state to running state, vice-verse, and maintaining the ready queue. On the other hand, non-preemptive scheduling does not suffer from the overhead of switching the process from running state to ready state.
  3. When a high priority process arrives frequently in the ready queue then the process with low priority has to wait for a long time, and it may have to starve, in preemptive scheduling. Whereas in the non-preemptive scheduling, if CPU is allocated to the process with larger burst time then the processes with smallest burst time may have to starve.
  4. The critical processes are allowed to access CPU whenever they arrive into the read queue. In this way preemptive scheduling is flexible. While non-preemptive scheduling is rigid because if a critical process enters the ready queue the process running CPU not disturbed.
  5. The Preemptive Scheduling has to maintain the integrity of shared data so it is cost associative but it is not the case with non-preemptive Scheduling.
  6. The main difference between these two schedules is that in non-preemptive scheduling, the CPU is allocated to the process till it completes its execution or switches from running state to waiting state. Whereas in preemptive scheduling the CPU is allocated to a process for a limited amount of time.


Comments and Discussions!

Load comments ↻

Copyright © 2024 All rights reserved.