10 Difference Between Preemptive And Non-Preemptive Scheduling With Example

SHARE

The processor scheduling (CPU scheduling) determines which processes are assigned to, and removed from the CPU, based on scheduling models such as preemptive and non-preemptive scheduling. CPU scheduling makes the full use of CPU resulting in a fast and efficient system.

preemptive vs non-preemptive scheduling

Usually, tasks in computer systems are assigned based on priorities. At some point, it is necessary to run a certain task before another although it is running. Therefore, the running task is interrupted for some time and resumes later when the prioritized task has finished execution. This is what is referred to as preemptive scheduling.  Preemptive scheduling is used when a process switches from running state to ready state or from waiting state to ready state.

In Non-preemptive scheduling, scheduling does not interrupt a process running CPU in the middle of execution. Instead, it waits for the process to complete its CPU burst time and then it can allocate the CPU to another process. Non-preemptive scheduling is the only method that can be used on certain hardware platforms because it does not require the special hardware for example a timer that is needed for preemptive scheduling.

The Difference

  1. Preemptive scheduling is whereby the processes with higher priorities are executed first. A process can be interrupted by another process in the middle of its execution.  On the other hand, non-preemptive scheduling is whereby once the CPU has been allocated to a process, the process keeps the CPU until it releases the CPU either by terminating or by switching to the waiting state.
  2. Non-preemptive scheduling can be described as rigid because even if a critical process enters the ready queue, the process running CPU is not interrupted. On the other hand, preemptive scheduling can be described as flexible because it allows the critical processes to access CPU as they arrive into the ready queue no matter what process is currently being executed.
  3. In preemptive scheduling, if a process with higher priority enters in a ready queue, the process with lower priority is removed while in non-preemptive scheduling once the process has been allocated to the CPU, it will complete its execution.
  4. In non-preemptive scheduling, the process cannot be scheduled whereas in the preemptive scheduling, the process can be scheduled.
  5. Preemptive scheduling can cause a problem when two processes share data because one may be interrupted in the middle of updating shared data structures. This is usually not the case with non-preemptive scheduling.
  6. Non-preemptive scheduling has no overhead of switching the process from running state to ready state whereas preemptive scheduling, has the overhead of switching the process from ready state to running state, running state to ready state.
  7. In preemptive scheduling, the CPU utilization is higher than in non-preemptive scheduling.
  8. In the non-preemptive scheduling, if the CPU is allocated to the process having larger burst time then the processes with small burst time may have to starve. In contrast, in preemptive scheduling, if a high priority process frequently arrives in the ready queue then the process with low priority has to wait for long, and it may have to starve.
  9. The preemptive scheduling is costly when compared to non-preemptive scheduling because it has to maintain the integrity of shared data.

Also Read: Difference Between Vectored And Non-vectored Interrupts

Preemptive Scheduling Vs. Non-Preemptive Scheduling In Tabular Form

BASIS OF COMPARISON PREEMPTIVE SCHEDULING NON-PREEMPTIVE SCHEDULING
Description Preemptive scheduling is whereby the processes with higher priorities are executed first. A process can be interrupted by another process in the middle of its execution.  Non-preemptive scheduling is whereby once the CPU has been allocated to a process, the process keeps the CPU until it releases the CPU either by terminating or by switching to the waiting state.  
Alternative Description Preemptive scheduling can be described as flexible because it allows the critical processes to access CPU as they arrive into the ready queue no matter what process is currently being executed.   Non-preemptive scheduling can be described as rigid because even if a critical process enters the ready queue, the process running CPU is not interrupted.
Process Execution In preemptive scheduling, if a process with higher priority enters in a ready queue, the process with lower priority is removed.   In non-preemptive scheduling once the process has been allocated to the CPU, it will complete its execution.
Process Scheduling In the preemptive scheduling, the process can be scheduled.   In non-preemptive scheduling, the process cannot be scheduled.  
Data Sharing Problem Preemptive scheduling can cause a problem when two processes share data because one may be interrupted in the middle of updating shared data structures. This is usually not the case with non-preemptive scheduling.  
Overhead Of Switching The Process Preemptive scheduling has the overhead of switching the process from ready state to running state, running state to ready state.   Non-preemptive scheduling has no overhead of switching the process from running state to ready state
CPU Utilization In preemptive scheduling, the CPU utilization is higher than in non-preemptive scheduling.   In non-preemptive scheduling, the CPU utilization is lower than in preemptive scheduling.
Processing In preemptive scheduling, if a high priority process frequently arrives in the ready queue then the process with low priority has to wait for long, and it may have to starve.   In the non-preemptive scheduling, if the CPU is allocated to the process having larger burst time then the processes with small burst time may have to starve.
Cost The preemptive scheduling is costly when compared to non-preemptive scheduling because it has to maintain the integrity of shared data.   The non- preemptive scheduling is less costly when compared to preemptive scheduling because it does not have to maintain the integrity of shared data.  

Also Read: Difference Between Process And Thread

Advantages and Disadvantages of Preemptive Scheduling over non-preemptive scheduling 

Preemptive scheduling allows the scheduler to control response times by taking the CPU away from a process that it decided has been running too long in order to let another process run. It incurs more overhead than non-preemptive scheduling since it has to deal with the overhead of context switching processes instead of allowing a process to run to completion or run until the next I/O operation or other system call. However, it allows for higher degrees of concurrency and better interactive performance.