操作系统 cpu调度_CPU调度| 操作系统
操作系統(tǒng) cpu調(diào)度
調(diào)度標(biāo)準(zhǔn) (Scheduling Criteria)
There are many criteria which have been suggested for comparing the CPU scheduling algorithms. The characteristics which are used for comparison and then used to determine the best algorithms, for this some of the criteria are given below:
已經(jīng)提出了許多標(biāo)準(zhǔn)來比較CPU調(diào)度算法。 下面列出了用于比較然后用于確定最佳算法的特性,其中一些標(biāo)準(zhǔn)如下:
CPU utilization
CPU利用率
This is the main task in which we have to keep the CPU as busy as possible. Its known, that CPU utilization may range from 0 to 100 percent, but in a case of the real system it should range from 40 percent for the low-level system to 90 percent for high level used system.
這是我們必須使CPU盡可能繁忙的主要任務(wù)。 眾所周知,CPU利用率可能在0到100%的范圍內(nèi),但是在實際系統(tǒng)中,CPU利用率的范圍應(yīng)該從低級系統(tǒng)的40%到高級系統(tǒng)的90%。
Throughput
通量
The number of processes which complete their execution per unit time it is called Throughput. In the case of CPU scheduling, CPU is busy in executing the process, then the work is being done, and the work completed per unit time can also be called as throughput.
每單位時間完成其執(zhí)行的進(jìn)程數(shù)稱為吞吐量。 在CPU調(diào)度的情況下,CPU忙于執(zhí)行進(jìn)程,然后完成工作,并且每單位時間完成的工作也稱為吞吐量。
Turnaround Time
周轉(zhuǎn)時間
This is an amount of time to execute a particular process. Turnaround time is the sum of the periods spent waiting to get into memory, executing on the CPU, waiting in the queue and doing I/O i.e. the interval between the time of submission of a process to the time of completion is the turnaround time.
這是執(zhí)行特定過程的時間。 周轉(zhuǎn)時間是等待進(jìn)入內(nèi)存,在CPU上執(zhí)行,在隊列中等待以及執(zhí)行I / O所花費的時間總和,即,從提交進(jìn)程的時間到完成時間之間的時間間隔就是周轉(zhuǎn)時間。
Waiting time
等待的時間
It is an amount of time in which a process has been waiting in the ready queue. It only affects the amount of time that a process spends waiting in the ready queue.
這是進(jìn)程在就緒隊列中等待的時間。 它僅影響進(jìn)程在就緒隊列中等待所花費的時間。
Response time
響應(yīng)時間
It is an amount of time in which the request was submitted until the first response is produced, not output.
這是在產(chǎn)生第一個響應(yīng)(而不是輸出)之前提交請求的時間。
In all these cases we need to maximize the CPU utilization and throughput, and to minimize the turnaround time, waiting time, and respond time.
在所有這些情況下,我們都需要最大化CPU利用率和吞吐量,并最小化周轉(zhuǎn)時間,等待時間和響應(yīng)時間。
調(diào)度算法 (Scheduling Algorithms)
Scheduling algorithms deal with the problems of deciding the process which is in the ready queue and need to be allocated in the CPU. There are some algorithms which are discussed below:
調(diào)度算法處理確定準(zhǔn)備隊列中需要在CPU中分配的進(jìn)程的問題。 下面討論了一些算法:
1. First-Come First-Served Scheduling
1. First-Come先服務(wù)調(diào)度
It is a simplest CPU scheduling algorithm. According to this, the process that requests the CPU first is allocated at the CPU first. FCFS is managed with the help of the FIFO queue. When a process enters into a ready queue it will link up at the tail of the queue and when the CPU is free it allocates the process at the head of the queue and by this running, the process is removed from the queue. This is a very simple algorithm for write and to understand.
它是最簡單的CPU調(diào)度算法。 據(jù)此,首先在CPU上分配首先請求CPU的處理。 借助FIFO隊列來管理FCFS。 當(dāng)進(jìn)程進(jìn)入就緒隊列時,它將在隊列的尾部鏈接,而當(dāng)CPU空閑時,它將進(jìn)程分配在隊列的開頭,并通過此運行將進(jìn)程從隊列中刪除。 這是用于編寫和理解的非常簡單的算法。
Consider the following process that arrives at a time 0 with the CPU burst time in milliseconds.
考慮以下過程,該過程在時間0到達(dá),CPU突發(fā)時間以毫秒為單位。
If the process arrive in the order of P1, P2, P3 in order of FCFS then the Gantt chart for this will be:
如果進(jìn)程按照FCFS的順序到達(dá)P1 , P2 , P3 ,則用于此的甘特圖將為:
i.e. average waiting time will be : (0+26+28)/3 = 18. The FCFS scheduling algorithm is non pre-emptive.
即平均等待時間為: (0 + 26 + 28)/ 3 = 18 。 FCFS調(diào)度算法是非搶先式的。
.minHeight{min-height: 250px;}@media (min-width: 1025px){.minHeight{min-height: 90px;}} .minHeight{min-height: 250px;}@media (min-width: 1025px){.minHeight{min-height: 90px;}}2. Shortest Job first scheduling
2.最短的作業(yè)優(yōu)先調(diào)度
This is a different approach in need of CPU scheduling. According to this algorithm when the CPU is free, the process will be assigned which will have the smallest next CPU burst. SJF is optimal which means it will provide the average waiting time for a given set of processes. Let us consider an example with the following set of processes, with the length of CPU burst time given in milliseconds.
這是需要CPU調(diào)度的另一種方法。 根據(jù)該算法,當(dāng)CPU空閑時,將分配下一個CPU突發(fā)最小的進(jìn)程。 SJF是最佳的,這意味著它將為給定的一組過程提供平均等待時間。 讓我們考慮以下一組進(jìn)程的示例,其中CPU突發(fā)時間的長度以毫秒為單位。
Gantt chart for this will be:
甘特圖將是:
i.e. average time by using SJF is (0+3+9+16)/4 =7 milliseconds. As SJF is an optimal algorithm which cannot be implemented at the level of short term CPU scheduling as there is no way to know that the length of the next CPU burst.
即使用SJF的平均時間為(0 + 3 + 9 + 16)/ 4 = 7毫秒。 由于SJF是一種最佳算法,無法在短期CPU調(diào)度級別上實現(xiàn),因為無法知道下一個CPU突發(fā)的長度。
3. Priority Scheduling
3.優(yōu)先調(diào)度
In this kind of algorithms, a priority is associated with a process and by that CPU will be allocated to the process which will have the highest priority. By this, we can conclude that larger the CPU burst, the lower the priority and vice versa. Let us consider an example with the following set of the process with the length of the CPU burst time given in milliseconds.
在這種算法中,優(yōu)先級與進(jìn)程相關(guān)聯(lián),并由此將CPU分配給優(yōu)先級最高的進(jìn)程。 這樣,我們可以得出結(jié)論,CPU突發(fā)越大,優(yōu)先級越低,反之亦然。 讓我們考慮以下過程集的示例,其中以毫秒為單位給出了CPU突發(fā)時間的長度。
In this case, the average waiting time is (0+1+6+16+18)/5 =8.2 milliseconds. Priority scheduling can be either pre-emptive or non-pre-emptive. A major problem with the priority scheduling is starvation which means low priority process never executes and the solution to the problem is aging. Aging is a technique of increasing the priority of the process which had wait in the system for a long time.
在這種情況下,平均等待時間為(0 + 1 + 6 + 16 + 18)/ 5 = 8.2毫秒。 優(yōu)先級調(diào)度可以是搶占式或非搶占式。 優(yōu)先級調(diào)度的一個主要問題是饑餓,這意味著永遠(yuǎn)不會執(zhí)行低優(yōu)先級的進(jìn)程,并且該問題的解決方案是老化。 老化是一種增加已在系統(tǒng)中等待很長時間的進(jìn)程的優(yōu)先級的技術(shù)。
4. Round Robin Scheduling
4.循環(huán)調(diào)度
The round robin scheduling algorithm is designed for a time-sharing system in which a small time is defined termed as time quantum. A time quantum is generally from the 10 to 100 milliseconds. For implementing the RR scheduling the CPU scheduler keeps the process for the ready queue and sets a timer to interrupt after the one-time quantum and then the process will be dispatched. If there are m processes in the queue and the time quantum is q then each process gets 1/m of the CPU time and by this, no process will wait for more than (m-1)q time units.
輪循調(diào)度算法是為分時系統(tǒng)設(shè)計的,在分時系統(tǒng)中,將定義為小時間的時間稱為時間量。 時間量通常為10到100毫秒。 為了實現(xiàn)RR調(diào)度,CPU調(diào)度程序保留準(zhǔn)備就緒隊列的進(jìn)程,并將計時器設(shè)置為在一次性運行時間后中斷,然后將分派該進(jìn)程。 如果隊列中有m個進(jìn)程,并且時間量為q,則每個進(jìn)程獲得1 / m的CPU時間,這樣,沒有一個進(jìn)程將等待超過(m-1)q個時間單位。
翻譯自: https://www.includehelp.com/operating-systems/cpu-scheduling.aspx
操作系統(tǒng) cpu調(diào)度
總結(jié)
以上是生活随笔為你收集整理的操作系统 cpu调度_CPU调度| 操作系统的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 判断是否大于_电动车是否属于机动车的辩论
- 下一篇: 什么是Apple Desktop Bus