操作系统(五):FCFS/SJF/非抢占优先级/RR
操作系統(五):FCFS/SJF/非搶占優先級/RR
一、題目1(書上170頁5.7)
5.4
5.4 Consider the following set of processes, with the length of the CPU burst time given in milliseconds:
The processes are assumed to have arrived in the order P1, P2, P3, P4, P5, all at time 0.
a. Draw four Gantt charts that illustrate the execution of these processes using the following scheduling algorithms: FCFS, SJF, nonpreemptive priority (a larger priority number implies a higher priority), and RR (quantum = 2).
b. What is the turnaround time of each process for each of the scheduling algorithms in part a?
c. What is the waiting time of each process for each of these scheduling algorithms?
d. Which of the algorithms results in the minimum average waiting time (over all processes)?
大致翻譯:這里有五個進程以P1,P2,P3,P4,P5的順序同時在0時刻到達,畫出FCFS,SJF,非搶占式優先級和RR(時間片長度為2)的甘特圖,寫出上述四種算法得輪轉時間、等待時間和最小平均等待時間。
知識點:對調度算法的理解,甘特圖的繪制。
二、做題1
1.概念1
(1)FCFS: 先到先服務(非搶占)
直接按到達順序先到先服務啦~
(2)SJF:最短作業優先調度(優先級調度的特例)(可搶占可非搶占)
執行時間短的先啦~
當到達時間不同時, 將 新來的執行時間 與 之前的剩余的執行時間 對比,短的優先~(就可能存在搶占啦)
(3)非搶占優先級:
就是多加了個優先級,優先級大的優先,執行時間少的優先~(注意看數字大的代表優先級大還是數字小代表優先級大)
(4)RR:非搶占輪轉調度
固定時間片!!!!也就是固定一個程序最多一次只能運行一個時間片的時間(如 時間片=2)
然后注意到達時間,不看優先級,按順序噢~
(5)搶占輪轉調度(第二題用)
考慮優先級、時間片、到達先后 ,時間相同的話按先到先服務
2.概念2
(1)周轉時間:從到達時間 到 執行完 所用的時間~
(2)等待時間:到達以后 等待的所有小時間相加
(3)平均等待時間:每個任務等待時間相加,除以總任務數
(4)CPU運行效率:非空轉時間占總時間的比例
3.做題啦
平均時間最短的就是SJF啦~
三、題目2(書上P170 5.8)
5.5
The following processes are being scheduled using a preemptive, roundrobin scheduling algorithm.
Each process is assigned a numerical priority,with a higher number indicating a higher relative priority. In addition to the processes listed below, the system also has an idle task (which consumes no CPU resources and is identified as [公式] ). This task has priority 0 and is scheduled whenever the system has no other available processes to run. The length of a time quantum is 10 units. If a process is preempted by a higher-priority process, the preempted process is placed at the end of the queue.
a. Show the scheduling order of the processes using a Gantt chart.
b. What is the turnaround time for each process?
c. What is the waiting time for each process?
d. What is the CPU utilization rate?
大致翻譯:這些進程將會被搶占式的輪轉調度算法所調度,每一個進程都擁有一個數字表示的優先級,數字大代表著高優先級,除了上述所說的進程,系統在空轉的時候會執行Pidle 進程(不消耗任何CPU資源),時間片的大小為10個時間單元,如果一個進程被高優先級的進程搶占,被搶占的進程將會放在隊列的末尾。
使用甘特圖畫出這些進程的調度情況,計算出每個進程的輪轉時間、等待時間和CPU的使用率。
知識點:搶占式RR算法
四、做題啦2
概念上面那題有噢
五、題目三
一個program~
看下面連接叭:https://zhuanlan.zhihu.com/p/83470448
總結
以上是生活随笔為你收集整理的操作系统(五):FCFS/SJF/非抢占优先级/RR的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: APS.NET MVC + EF (01
- 下一篇: java getopt_sys.argv