作者genius945 (添财)
看板Grad-ProbAsk
标题Re: [理工] [OS] scheduling
时间Sat Oct 15 20:57:21 2011
※ 引述《SiriusCloud (古月小枫)》之铭言:
: 标题: Re: [理工] [OS] scheduling
: 时间: Sat Oct 15 01:10:22 2011
:
: ※ 引述《ceo890710 (Drinking)》之铭言:
: : 恐龙的习题
: : Consider a system running ten IO-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 tasks 10
: : milliseconds to complete.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. .. .. .. .. 10 millisecond
: : 不太懂这题的意思 请问怎麽算..
:
:
: a. 假设原本做完是100% utilization
: 现在花了0.1 ms 去做context switching
: 因为 time quantum 是 1 ms
: 所以 CPU utilization 是--------> 1 / (1 + 0.1) = 91 %
:
: b. 现在 time quantum 变成 10 ms
: I/O bound 最多 花 1ms
: 每 1 ms 发生一次 context switching
: 加上 I/O 完成 要花 10 ms 又会再发生一次 context switching
: 因此
这边我认为是I/O bound使用CPU的时间加上 CPU bound使用cpu的时间
跟I/O完成无关
: I/O + I/O完成 I/O做完10ms後换成CPU + 1次 context switching
: ^^^^^^^^ ^^^^
: (10 + 10) / (10 * 1.1) + 10.1 = 94%
: ^^^^^^^^^^^^
: I/O 每 1 ms发生一次 context switching
:
: 推 ceo890710:想请问第二题 为什麽I/O完成也要再多10呢.. 10/15 08:49
: → ceo890710:另外~这是以一次I/O工作来讨论的吗? 因为他有10个I/O 10/15 08:50
我的想法跟S大不一样,我的作法是不管I/O完成的时间
只要在I/O bound task下一次分配到time quantum的时候
他自身issue的I/O operation已经处理完,不会使得此task还在等待就好
如此下次轮到此task,又会再issue一个IO operation,於是又要context switching
因为总共有10个IO bound跟1个CPU bound tasks
每个IO bound task 只要处理1ms,就会因需要等待I/O operation
而context switching到其他的task
也就是说每个I/O bound task的cpu utilization是1/1.1
而cpu bound task则是 10/10.1 (这应该没问题)
换句话说以各任务分配到一个quantum来说,总共是10+10/10*1.1 + 10.1
然後题目有提到这些都是long-running tasks,就当作他们做不完吧XD
所以之後第二轮的执行还是跟第一轮一样
因此cpu utilization还是如同之前算的
就跟第一题一样的道理
第一题无论如何,每个quantum都是1/1.1
所以在此cpu scheduling之下, cpu utilization就是1/1.1
至於题目为什麽要给10个I/O bound跟1个 cpu bound
吃饱没事想了一下
因为每个I/O operation需要10 ms处理
所以若是没有另外9+1个 tasks 吃掉时间
则在第一题,I/O bound task等到下次轮到他的time quantum时
会因为还在等待I/O operation的处理导致他直接跳过
这样搞下去CPU utilization应该会很难算...
这是我想的啦,也不知道有没有错 大家讨论一下吧!
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 114.27.250.59
1F:推 ceo890710:我之前的方向想错了..如果是这样那我懂了~谢谢!! 10/15 22:30