Prerequisite – CPU Scheduling
1. Preemptive Scheduling:
Preemptive scheduling is used when a process switches from running state to ready state or from waiting state to ready state. The resources (mainly CPU cycles) are allocated to the process for the limited amount of time and then is taken away, and the process is again placed back in the ready queue if that process still has CPU burst time remaining. That process stays in ready queue till it gets next chance to execute.
2. Non-Preemptive Scheduling:
Non-preemptive Scheduling is used when a process terminates, or a process switches from running to waiting state. In this scheduling, once the resources (CPU cycles) is allocated to a process, the process holds the CPU till it gets terminated or it reaches a waiting state. In case of non-preemptive scheduling does not interrupt a process running CPU in middle of the execution. Instead, it waits till the process complete its CPU burst time and then it can allocate the CPU to another process.
Key Differences Between Preemptive and Non-Preemptive Scheduling:
- In preemptive scheduling the CPU is allocated to the processes for the limited time whereas in Non-preemptive scheduling, the CPU is allocated to the process till it terminates or switches to waiting state.
- The executing process in preemptive scheduling is interrupted in the middle of execution when higher priority one comes whereas, the executing process in non-preemptive scheduling is not interrupted in the middle of execution and wait till its execution.
- In Preemptive Scheduling, there is the overhead of switching the process from ready state to running state, vise-verse, and maintaining the ready queue. Whereas in case of non-preemptive scheduling has no overhead of switching the process from running state to ready state.
- In preemptive scheduling, if a high priority process frequently arrives in the ready queue then the process with low priority has to wait for a long, and it may have to starve. On the other hands, in the non-preemptive scheduling, if CPU is allocated to the process having larger burst time then the processes with small burst time may have to starve.
- Preemptive scheduling attain flexible by allowing the critical processes to access CPU as they arrive into the ready queue, no matter what process is executing currently. Non-preemptive scheduling is called rigid as even if a critical process enters the ready queue the process running CPU is not disturbed.
- The Preemptive Scheduling has to maintain the integrity of shared data that’s why it is cost associative as it which is not the case with Non-preemptive Scheduling.
|Paramenter||PREEMPTIVE SCHEDULING||NON-PREEMPTIVE SCHEDULING|
|Basic||In this resources(CPU Cycle) are allocated to a process for a limited time.||Once resources(CPU Cycle) are allocated to a process, the process holds it till it completes its burst time or switches to waiting state.|
|Interrupt||Process can be interrupted in between.||Process can not be interrupted untill it terminates itself or its time is up.|
|Starvation||If a process having high priority frequently arrives in the ready queue, low priority process may starve.||If a process with long burst time is running CPU, then later coming process with less CPU burst time may starve.|
|Overhead||It has overheads of scheduling the processes.||It does not have overheads.|
|Cost||cost associated||no cost associated|
|CPU Utilization||In preemptive scheduling, CPU utilization is high.||It is low in non preemptive scheduling.|
|Examples||Examples of preemptive scheduling are Round Robin and Shortest Remaining Time First.||Examples of non-preemptive scheduling are First Come First Serve and Shortest Job First.|
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
- Difference between Preemptive and Non-preemptive CPU scheduling algorithms
- Relation in FCFS and Preemptive Priority Scheduling Algorithm
- Relation between Preemptive Priority and Round Robin Scheduling Algorithm
- Program for Shortest Job First (or SJF) CPU Scheduling | Set 1 (Non- preemptive)
- Program for Shortest Job First (SJF) scheduling | Set 2 (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 Preemptive and Cooperative Multitasking
- Difference between Priority Scheduling and Round Robin (RR) CPU scheduling
- Difference between Priority scheduling and Shortest Job First (SJF) CPU scheduling
- Difference between Multi Level Queue Scheduling (MLQ) and Priority Scheduling
- Implementation of Non-Preemptive Shortest Job First using Priority Queue
- Multilevel Feedback Queue Scheduling (MLFQ) CPU Scheduling
- Difference between First Come First Served (FCFS) and Round Robin (RR) Scheduling Algorithm
- Difference between Turn Around Time (TAT) and Waiting Time (WT) in CPU Scheduling
- Advantages and Disadvantages of various CPU scheduling algorithms
- Difference between Seek Time and Rotational Latency in Disk Scheduling
- Difference between Seek Time and Disk Access Time in Disk Scheduling
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.