Compare the Difference Between Similar Terms

Difference Between Preemptive and Nonpreemptive Scheduling in OS

Key Difference – Preemptive vs Nonpreemptive Scheduling in OS
 

A process is a program in execution. A computer should perform many tasks at the same time. Therefore, the CPU should get processes and execute them. Sometimes it is necessary to execute some processes than the other processes. At that point, the running process is interrupted, and CPU is allocated to the new process. After the task is completed, the CPU is allocated back to the previous process. The scheduling according to this mechanism is known as preemptive scheduling. If the running process, cannot be interrupted and it is compulsory to execute the running process, then it is known as nonpreemptive scheduling. This article discusses the difference between the preemptive and nonpreemptive scheduling in an operating system. The preemptive scheduling is the process scheduling mechanism through which a process that can be interrupted by another process in the middle of its execution. The nonpreemptive scheduling is the process scheduling mechanism through which one process starts execution only after the previous process terminates. That is the key difference between Preemptive and Nonpreemptive Scheduling in OS.

CONTENTS

1. Overview and Key Difference
2. What is Preemptive Scheduling in OS
3. What is Nonpreemptive Scheduling in OS
4. Similarities Between Preemptive and Nonpreemptive Scheduling in OS
5. Side by Side Comparison – Preemptive vs Nonpreemptive Scheduling in OS in Tabular Form
6. Summary

What is Preemptive Scheduling in OS?

Round Robin Scheduling is an example of preemptive scheduling. Each process gets a small amount of CPU time. It is usually 10 to 100 milliseconds. This small unit of data is also known as time quantum. After this time has elapsed, the process is preempted and added to the end of the ready queue. Assume that there are 4 processes as P1, P2, P3 and P4. The CPU burst times in milliseconds are as follows.  The time quantum is 20.

Figure 01: Example of Round Robin Scheduling

The P1 process executes till 20. There is another 33ms left. Then the P2 executes. As the time quantum is 20 and the required time P2 is 17ms, P2 will execute for 17ms. So, the P2 process is completed. Then the chance is given to P3. It will execute for 20ms. The rest is 48ms. Then the P4 will execute for 20ms. It has 4ms to complete the total process. Again, the P1 will execute for 20ms. It has another 13ms to completing finish the process. The change is given to P3. It will execute for 20ms, and it has another 28ms to finish completely. The P4 executes. It only has 4ms. Therefore, P4 completes the execution. P2 and P4 have already finished. The remaining processes are P1 and P3. The chance is given to P3. It had 13ms to complete, so it completes. Now the only remaining process is P3. It has 28ms to complete. So P3 will run for 20ms. The rest is 8ms. All other processes have already completed executing. Therefore, again the rest of 8ms of P3 will execute. Likewise, each process gets a chance to execute.

What is Nonpreemptive Scheduling in OS?

First Come First Served (FCFS) scheduling can be taken as an example of nonpreemptive scheduling. The process that requests first is allocated to the CPU first. This scheduling is easily managed by the First In First Out (FIFO) queue. If there are processes came in order as P1, P2 and P3, then the chance is first given to P1. After it is completed, P2 will execute. When P2 completes, the P3 will execute. Assume that there are 3 processes as P1, P2 and P3 with CPU burst times in milliseconds as follows.

Figure 02: Example of FCFS Scheduling

According to the above, P1 will execute. Once it is completed, the process P2 is executed for 3ms. Now the remaining process is P3. Then it will execute. The waiting time for P1 is zero. The process P2 had to wait 24ms, and the process P3 had to wait 27ms. If the processes arrived in order P2, P3 and P1 then P2 will complete first. Next P3 will complete, and finally, P1 will complete.

What is the Similarity Between Preemptive and Nonpreemptive Scheduling in OS?

What is the Difference Between Preemptive and Nonpreemptive Scheduling in OS?

Preemptive vs Nonpreemtive Scheduling in OS

The preemptive scheduling is the process scheduling mechanism through which a process can be interrupted by another process in the middle of its execution. The nonpreemptive scheduling is the process scheduling mechanism through which one process starts execution only after the previous process terminates.
 Process Interruption
In preemptive scheduling, the processes can be interrupted. In nonpreemptive scheduling, the processes can be interrupted.
CPU Utilization
In preemptive scheduling, the CPU utilization is higher than nonpreemptive scheduling. In nonpreemptive scheduling, the CPU utilization is minimum comparing to preemptive scheduling.
 Flexibility
Preemptive scheduling is flexible. Nonpreemptive scheduling is not flexible.

Summary – Preemptive vs Nonpreemptive Scheduling in OS 

There are multiple processes running on a computer. When each process executes, the CPU is allocated to that specific process. Sometimes, it is necessary to stop the execution of the current process and to give priority to another process. Processes scheduling mechanisms can be preemptive or nonpreemptive.  The preemptive scheduling is the process scheduling mechanism through which process can be interrupted by another process in the middle of its execution. The nonpreemptive scheduling is the process scheduling mechanism though which one process starts execution only after the previous process terminates. This is the difference between Preemptive and Nonpreemptive Scheduling in OS.

Download the PDF of Preemptive vs Nonpreemptive Scheduling in OS

You can download the PDF version of this article and use it for offline purposes as per citation note. Please download the PDF version here: Difference Between Preemptive and Nonpreemptive Scheduling in OS

Reference:

1.What is pre-Emptive and non-Preemptive scheduling?. Available here  
2.Point, Tutorials. “Operating System Scheduling algorithms.”, Tutorials Point. 8 Jan. 2018. Available here 
3.“What are pre-Emptive and non-Preemptive terms in context of OS ?” GeeksforGeeks Q&A. Available here