操作系统抢占式优先级调度
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.
顾名思义,调度取决于进程的优先级,而不是突发时间。 因此,在这种情况下,进程还必须在其详细信息中具有优先级号,操作系统将根据该优先级号对其进行调度。
For example, suppose we have 4 processes: P1, P2, P3 and P4 and they enter the CPU as follows:
例如,假设我们有4个进程: P1 , P2 , P3和P4 ,它们按如下方式进入CPU:
Note: Here, lower the priority number, higher is the priority.
注意:此处,优先级数字越低,优先级越高。
As per the non-preemptive priority scheduling, the processes will be executed as follows:
根据非抢先优先级调度 ,将按以下方式执行过程:
Gant Chart:
甘特图:
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.
在时间0只有P1可用,因此无论优先级如何都将首先执行它,并且在完成之前不能抢占它。
When it is completed at 4th-time unit, we have all P2, P3, and P4 available. So, they are executed according to their priorities.
当以第 4 次单位完成时,我们将拥有所有P2 , P3和P4 。 因此,将根据优先级执行它们。
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
翻译自: https://www.includehelp.com/operating-systems/priority-scheduling-non-preemptive.aspx
操作系统抢占式优先级调度