Grad-ProbAsk 板


LINE

19.Consider that a system scheduls three processes P1,P2,P3 using Round-robin with time quantum=2 units of time. These three processes arrive in the order P1,P2,P3, all ready at time 0. The three processes share a resource R, which is protected by a mutex lock. The first process P1 runs 3 units of time, block the resource R 3 units of time,unlocks this resource,and then runs 1 unit of time before it completes. Let this execution of P1 be denoted by {3,R(3),1}. The execution of the second process P2 and the third process P3 are denoted by {2,R(1),3} and {2,R(2),2}, respectively. Let waiting queues be FIFO. which one(s) of the following is(are) true? A. The total number of context switches is not less than 9. B. T2 has the longest turnaround time. C. Decreasing P1's execution time from {3,R(3),1} to {3,R(1),1} reduces P2's turnaround time. D. Increasing P1's execution time from {3,R(3),1} to {4,R(3),1} reduces P2's turnaround time. 答案给ACD 但我自己算是只有A对 @@ 原本: | P1 | P2 | P3 | P1 | P2 | P3 | P2 | P1 | time 0 2 4 5 6 7 8 9 11 12 13 ^^^ ^^^^^^^^^^^^^^^^ R(1) R(2) R(3) time4~5 P2执行R(1) time6~8 P3执行R(2) time8~11 P1执行R(3) (C)选项的结果和原本一样,P2的turnaround time没变 (D)选项: P2的turnaround time增加 | P1 | P2 | P3 | P1 | P2 | P3 | P2 | P1 | time 0 2 4 6 8 10 12 13 14 不知道我哪里算错.. 有高手可以帮我解答吗... 感恩 --



※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 114.34.133.127
1F:→ ybite:关键似乎在mutex lock上? 01/17 19:35
2F:→ dacvidania:我有注意到mutex,应该是一次只能1 process block的意思 01/17 19:52
3F:→ dy957:我觉得题目意思是lock被process占用,还没用完时就算时间到了 01/17 20:05
4F:→ dy957:被换成其他process也不能执行吧@@ 01/17 20:06
5F:→ dy957:所以顺序可能是P1 P2 P3 P1 P2(不能执行)P3(不能执行)... 01/17 20:06
6F:→ dacvidania:楼上的意思是某Pi blocks resource时 其他process此时 01/17 20:34
7F:→ dacvidania:就无法得到CPU吗? 01/17 20:34
8F:→ dy957:应该是可以得到CPU 但是没办法得到那个resource 所以不能往 01/17 20:49
9F:→ dy957:下执行吧 要等到process释放那个资源 其他process才能执行 01/17 20:51
10F:→ dacvidania:那我的算法跟你的一样...不过不会没办法执行耶 01/17 21:01
※ 编辑: dacvidania 来自: 114.34.133.127 (01/17 21:06)
11F:→ dacvidania:还是我哪里算错... 01/17 21:19
12F:推 aoqq12:我一开始也用你的算法 01/17 22:29
13F:→ aoqq12:不过後来试另外个方法 我也不知道正不正确啦 01/17 22:29
14F:→ aoqq12:就 R(3)的意思应该是持有资源还是要用CPU去执行  01/17 22:30
15F:→ aoqq12:所以P2执行完 他要等到下次拿到CPU才会占用resource 01/17 22:31
16F:→ aoqq12:试一试结果是对的 01/17 22:31
17F:→ aoqq12:所以这题应该是考观念 不能跟I/O混淆 他只是拿共享资料 01/17 22:32
18F:→ aoqq12:不是发出block 01/17 22:33
19F:→ dacvidania:了解了~~谢谢 不过那个resource题目也没说是什麽... 01/17 22:40
20F:→ dacvidania:如果是印表机之类那就是IO了 01/17 22:42
21F:→ aoqq12:对= = 所以看到交大的排班先直接跳过写下一题 01/17 22:44
22F:→ aoqq12:有时间再回来写好了。。  01/17 22:44
23F:→ dacvidania:总觉得他是故意要让人家以为是IO... 01/17 22:44
24F:→ aoqq12:不过他其实有提到是lock的 so...还是细心!!跟英文好 01/17 22:46
※ 编辑: dacvidania 来自: 114.34.133.127 (01/17 23:18)
25F:→ sneak: 试一试结果是对的 https://daxiv.com 09/11 14:09







like.gif 您可能会有兴趣的文章
icon.png[问题/行为] 猫晚上进房间会不会有憋尿问题
icon.pngRe: [闲聊] 选了错误的女孩成为魔法少女 XDDDDDDDDDD
icon.png[正妹] 瑞典 一张
icon.png[心得] EMS高领长版毛衣.墨小楼MC1002
icon.png[分享] 丹龙隔热纸GE55+33+22
icon.png[问题] 清洗洗衣机
icon.png[寻物] 窗台下的空间
icon.png[闲聊] 双极の女神1 木魔爵
icon.png[售车] 新竹 1997 march 1297cc 白色 四门
icon.png[讨论] 能从照片感受到摄影者心情吗
icon.png[狂贺] 贺贺贺贺 贺!岛村卯月!总选举NO.1
icon.png[难过] 羡慕白皮肤的女生
icon.png阅读文章
icon.png[黑特]
icon.png[问题] SBK S1安装於安全帽位置
icon.png[分享] 旧woo100绝版开箱!!
icon.pngRe: [无言] 关於小包卫生纸
icon.png[开箱] E5-2683V3 RX480Strix 快睿C1 简单测试
icon.png[心得] 苍の海贼龙 地狱 执行者16PT
icon.png[售车] 1999年Virage iO 1.8EXi
icon.png[心得] 挑战33 LV10 狮子座pt solo
icon.png[闲聊] 手把手教你不被桶之新手主购教学
icon.png[分享] Civic Type R 量产版官方照无预警流出
icon.png[售车] Golf 4 2.0 银色 自排
icon.png[出售] Graco提篮汽座(有底座)2000元诚可议
icon.png[问题] 请问补牙材质掉了还能再补吗?(台中半年内
icon.png[问题] 44th 单曲 生写竟然都给重复的啊啊!
icon.png[心得] 华南红卡/icash 核卡
icon.png[问题] 拔牙矫正这样正常吗
icon.png[赠送] 老莫高业 初业 102年版
icon.png[情报] 三大行动支付 本季掀战火
icon.png[宝宝] 博客来Amos水蜡笔5/1特价五折
icon.pngRe: [心得] 新鲜人一些面试分享
icon.png[心得] 苍の海贼龙 地狱 麒麟25PT
icon.pngRe: [闲聊] (君の名は。雷慎入) 君名二创漫画翻译
icon.pngRe: [闲聊] OGN中场影片:失踪人口局 (英文字幕)
icon.png[问题] 台湾大哥大4G讯号差
icon.png[出售] [全国]全新千寻侘草LED灯, 水草

请输入看板名称,例如:WOW 或 站内搜寻

TOP