In CPU Scheduling, we have two types of scheduling, Let’s have a look at them:
In this, a scheduler may preempt a low priority running process anytime when a high priority process enters into a ready state. When scheduling takes from either of below circumstances it is preemptive scheduling –
- When a process switches from the running state to the ready state (for example, when an interrupt occurs).
- When a process switches from the waiting state to the ready state (for example, at completion of I/)).
In this, once a process enters the running state it cannot be preempted until it completes it’s allocation time. When scheduling takes place only under below circumstances we say that the scheduling scheme is non-preemptive or cooperative. –
- When a process switches from the running state to the waiting state (for example, as the result of an I/O request or an invocation of wait() for the termination of a child process).
- When a process terminates.
Let’s see the difference between Preemptive Scheduling and Non-Preemptive Scheduling:
|S.No.||Preemptive Scheduling||Non-Preemptive Scheduling|
|1.||The CPU is allocated to the processes for a certain amount of time.||The CPU is allocated to the process till it ends it’s execution or switches to waiting state.|
|2.||The executing process here is interrupted in the middle of execution.||The executing process here is not interrupted in the middle of execution.|
|3.||It usually switches the process from ready state to running state, vise-versa, and maintains the ready queue.||It does not switch the process from running state to ready state.|
|4.||Here, if a process with high priority frequently arrives in the ready queue then the process with low priority has to wait for long, and it may have to starve.||Here, if CPU is allocated to the process with larger burst time then the processes with small burst time may have to starve.||5.||It is quite flexible because the critical processes are allowed to access CPU as they arrive into the ready queue, no matter what process is executing currently.||It is rigid as even if a critical process enters the ready queue the process running CPU is not disturbed.||6.||This is cost associative as it has to maintain the integrity of shared data.||This is not cost associative.|
Preemptive scheduling is better than non-preemptive scheduling or vise-versa can’t be said definitely. It depends on how a scheduling minimizes the average waiting time of the processes and maximizes CPU utilization.
Attention reader! Don’t stop learning now. Get hold of all the important CS Theory concepts for SDE interviews with the CS Theory Course at a student-friendly price and become industry ready.
- Difference between Preemptive Priority based and Non-preemptive Priority based CPU scheduling algorithms
- Preemptive and Non-Preemptive Scheduling
- Program for Shortest Job First (or SJF) CPU Scheduling | Set 1 (Non- preemptive)
- Program for Preemptive Priority CPU Scheduling
- First Come, First Serve – CPU Scheduling | (Non-preemptive)
- Shortest Job First (or SJF) CPU Scheduling Non-preemptive algorithm using Segment Tree
- Difference between Priority Scheduling and Round Robin (RR) CPU scheduling
- Difference between Priority scheduling and Shortest Job First (SJF) CPU scheduling
- Multilevel Feedback Queue Scheduling (MLFQ) CPU Scheduling
- Difference between SJF and LJF CPU scheduling algorithms
- Difference between FCFS and SJF CPU scheduling algorithms
- Difference between SJF and SRJF CPU scheduling algorithms
- Difference between SRJF and LRJF CPU scheduling algorithms
- Difference between First Come First Served (FCFS) and Longest Job First (LJF) CPU scheduling algorithms
- Difference between EDF and LST CPU scheduling algorithms
- Difference between Multilevel Queue (MLQ) and Multi Level Feedback Queue (MLFQ) CPU scheduling algorithms
- Difference between LJF and LRJF CPU scheduling algorithms
- Relation between Preemptive Priority and Round Robin Scheduling Algorithm
- Relation in FCFS and Preemptive Priority Scheduling Algorithm
- Program for Shortest Job First (SJF) scheduling | Set 2 (Preemptive)
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.