Difference Between Preemptive and Nonpreemptive Scheduling in OS
Difference Between Preemptive and Nonpreemptive Scheduling in OS
Nonpreemptive Scheduling in OS
www.differencebetween.com
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.
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.
Reference: