東南大學《操作系統》課程作業 - 第五章


1 - Discuss how the following pairs of scheduling criteria conflict in certain settings.
a. CPU utilization and response time
b. Average turnaround time and maximum waiting time
c. I/O device utilization and CPU utilization

a. 要想最大化利用CPU,應減少CPU的上下文切換開銷。假設每次上下文切換耗時固定,則只能減少上下文切換次數。這會導致進程的響應時間變長。
b. 要想最小化平均周轉時間,盡快周轉進程,則需要優先執行耗時最短的進程。這可能使得長耗時進程飢餓,導致最大等待時間變長。
c. 要想最大化利用CPU,應減少CPU的上下文切換開銷。要想最大化IO設備利用,應在它們一准備好時就進行調用,這將導致CPU發生上下文切換。

2 - Consider the exponential average formula used to predict the length of the next CPU burst. What are the implications of assigning the following values to the parameters used by the algorithm?
a. α = 0 and τ0 = 100 milliseconds
b. α = 0.99 and τ0 = 10 milliseconds

根據指數平均公式\(τ_{(n+1)}=αt_n+(1-α) τ_n\)可知:
a. \(τ_{(n+1)}=τ_n\),估計值將始終為100毫秒;
b. \(τ_{(n+1)}=0.99t_n+0.01τ_n≈t_n\),即預測值將會很大程度上接近當前CPU執行的用時,而對過往歷史幾乎沒有記憶。

3 - Consider the following set of processes, with the length of the CPU burst given in milliseconds:
image
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, non-preemptive 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)?

image
image

4 - The following processes are being scheduled using a preemptive, priority-based, round-robin scheduling algorithm.
image
Each process is assigned a numerical priority, with a higher number indicating a higher relative priority. The scheduler will execute the highest priority process. For processes with the same priority, a round-robin scheduler will be used with a time quantum of 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?

規則如下:
優先級數字越大,優先級越高;搶占式的優先級調度;相同優先級則采用RR調度,時間片為10;進程被搶占時退到隊列尾部。
image
image

5 - Which of the following scheduling algorithms could result in starvation?
a. First-come, first-served
b. Shortest job first
c. Round robin
d. Priority

SJF算法會造成飢餓。如果一直有短時項目進入,則長時項目無法被執行。
優先級算法會造成飢餓。如果一直有高優先級項目進入,則低優先級項目無法被執行。

6 - Consider a variant of the RR scheduling algorithm where the entries in the ready queue are pointers to the PCBs.
a. What would be the effect of putting two pointers to the same process in the ready queue?
b. What would be the major advantages and disadvantages of this scheme?
c. How would you modify the basic RR algorithm to achieve the same effect without the duplicate pointers?

a. 該RR算法按指針訪問需要輪轉的進程。兩個指針指向同一個PCB會使得該進程分配到的時間片為兩個單位時間片,該進程會兩次出現在就緒隊列中。這相當於對這個進程有“偏好”的效果。
b. 該方案的優點是在不改變調度算法的前提下,以簡單的方式為某些進程分配更高的優先級。缺點是需要維護較多的指針,並且在查找特定進程時必須遍歷指針來訪問PCB。
c. 使得傳統RR在一個輪轉周期中支持分配兩個時間片給同一個進程,或者允許進程申請更大的時間片。

7 - Consider a system running ten I/O-bound tasks and one CPU-bound task. Assume that the I/O-bound tasks issue an I/O operation once for every millisecond of CPU computing and that each I/O operation takes 10 milliseconds to complete. Also assume that the context switching overhead is 0.1 millisecond and that all processes are long-running tasks. What is the CPU utilization for a round-robin scheduler when:
a. The time quantum is 1 millisecond
b. The time quantum is 10 milliseconds

a. 考慮一個時間片。1ms發生1次因I/O受限任務的上下文切換,耗時0.1ms。則CPU利用率為1/1.1×100%=90.9%。
b. 考慮一個時間片。10ms發生10次因I/O受限任務的上下文切換,耗時1ms。在時間片末尾,首個I/O受限任務完成,發生1次上下文切換,耗時0.1ms。綜上,CPU利用率為10/11.1=90.1%。


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM