×

Operating System Tutorial

Operating System Practice

Non-Preemptive Priority Scheduling Algorithm

In this tutorial, we will learn about the non-preemptive priority scheduling algorithm in an operating system with the help of an example. By Monika Sharma Last updated : May 07, 2023

What is a non-preemptive priority scheduling algorithm?

Priority scheduling is a type of scheduling algorithm used by the operating system to schedule the processes for execution. The priority scheduling has both the preemptive mode of scheduling and the non-preemptive mode of scheduling. Here, we will discuss the non-preemptive priority scheduling algorithm.

As the name suggests, the scheduling depends upon the priority of the processes rather than its burst time. So, the processes, in this case, must also have the priority number in its details on the basis of which the OS will schedule it.

Non-Preemptive Priority Scheduling Algorithm Example

For example, suppose we have 4 processes: P1, P2, P3 and P4 and they enter the CPU as follows:

Note: Here, lower the priority number, higher is the priority.

priority scheduling in OS (1)

As per the non-preemptive priority scheduling, the processes will be executed as follows:

Gant Chart

priority scheduling in OS (2)

Explanation

  • There is only P1 available at time 0, so it will be executed first irrespective of the priority, and it cannot be preempted in between before its completion.
  • When it is completed at 4th-time unit, we have all P2, P3, and P4 available. So, they are executed according to their priorities.
priority scheduling in OS (3)
Total Turn Around Time = 4 + 7 + 9 + 2
            = 22 milliseconds
Average Turn Around Time= Total Turn Around Time / Total No. of Processes
            = 22 / 4
            = 5.5 milliseconds

Total Waiting Time = 0 + 5 + 6 + 0
            = 11 milliseconds
Average Waiting Time = Total Waiting Time / Total No. of Processes
            = 11 / 4
            = 2.75 milliseconds



Comments and Discussions!

Load comments ↻





Copyright © 2024 www.includehelp.com. All rights reserved.