天天看點

作業系統搶占式優先級排程_作業系統中的優先級排程(非搶先)

作業系統搶占式優先級排程

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

作業系統搶占式優先級排程