[理工] 一題OS

看板Grad-ProbAsk作者 (小YO)時間13年前 (2011/01/28 13:27), 編輯推噓2(2011)
留言13則, 5人參與, 最新討論串1/2 (看更多)
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 millisecond to compute.Also assume that the context-switching overhead is 0.1 millisecond and that all processes are long-running tasks. Describe the CPU utilization for a round-robin scheduler when: (a)The time quantum is 1 millisecond (b)The time quantum is 10 milliseconds -- sol: (a) 1.0/(1.0+0.1) = 1/1.1 = 91% (b) 20/((10*1.1)+10.1) = 20/21.1 = 94% -- 這題考滿多次的,可是就是沒有很了解怎麼解這題... 可以請高手詳細說明一下嗎?(尤其是(b)小題) 謝謝!! -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 114.39.13.219 ※ 編輯: boy5548 來自: 114.39.13.219 (01/28 13:29)

01/28 20:09, , 1F
io bound 每做1 time unit 就會一次context switch so
01/28 20:09, 1F

01/28 20:11, , 2F
10個IO bound 10*1.1=11 cpu bound 剛好10 time unit
01/28 20:11, 2F

01/28 20:12, , 3F
做完也要一次context switch so 10+0.1=10.1 所以 實際用
01/28 20:12, 3F

01/28 20:12, , 4F
在execute 的時間/總時間 20/21.1 成立
01/28 20:12, 4F

01/28 23:26, , 5F
請問為什麼cpu bound要做10 time unit?
01/28 23:26, 5F

01/28 23:27, , 6F
而且為什麼剛好10 time unit做完也要一次context-switch?
01/28 23:27, 6F

01/28 23:34, , 7F
因為time quantum 是10
01/28 23:34, 7F

01/29 19:26, , 8F
因為他寫 long-time 表示這些行程一直在跑
01/29 19:26, 8F

01/29 23:27, , 9F
有個更簡單的想法你試試。。你就畫個 ready queue
01/29 23:27, 9F

01/29 23:28, , 10F
然後cpu bound一開始就在裡面 你每隔1m就抓一個i/o bound
01/29 23:28, 10F

01/29 23:28, , 11F
放進去ready queue
01/29 23:28, 11F

01/29 23:29, , 12F
在照順序去給他cpu就好了
01/29 23:29, 12F

09/11 14:11, , 13F
在execute 的時 https://daxiv.com
09/11 14:11, 13F
文章代碼(AID): #1DGbF0eh (Grad-ProbAsk)
討論串 (同標題文章)
文章代碼(AID): #1DGbF0eh (Grad-ProbAsk)