Home » Operating Systems

Differences between Preemptive and Non-Preemptive Scheduling

Preemptive vs non-preemptive scheduling: In this article, we are going to study the differences between preemptive and non-preemptive scheduling.
Submitted by Monika Jha, on November 26, 2019

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

1) 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.

2) 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.

Differences between Preemptive and Non-Preemptive Scheduling in OS

  • 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.
  • 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.
  • 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.
  • 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.
  • 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.
  • 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.

References:

ADVERTISEMENT
ADVERTISEMENT




Comments and Discussions!




Languages: » C » C++ » C++ STL » Java » Data Structure » C#.Net » Android » Kotlin » SQL
Web Technologies: » PHP » Python » JavaScript » CSS » Ajax » Node.js » Web programming/HTML
Solved programs: » C » C++ » DS » Java » C#
Aptitude que. & ans.: » C » C++ » Java » DBMS
Interview que. & ans.: » C » Embedded C » Java » SEO » HR
CS Subjects: » CS Basics » O.S. » Networks » DBMS » Embedded Systems » Cloud Computing
» Machine learning » CS Organizations » Linux » DOS
More: » Articles » Puzzles » News/Updates

© https://www.includehelp.com some rights reserved.