作者mickeyha (M*schief)
看板Grad-ProbAsk
标题[理工] [OS] Dead Lock
时间Tue Nov 1 23:10:30 2011
洪逸 作业系统金宝典
p.5-59
47.Consider a snapshit if the system as shown below. Upon the
next request, P1 makes a request for ( 0 4 2 0) and is granted
immediately. What is the minimum number of initial instances
(i.e. the total number of instances before any [rpcess enters the
system) for each resource type to make sure system still in a
safe after P1's request is granted? (答案请以(a b c d) 方式表示)
Allocation Max
A B C D A B C D
P0 0 0 1 2 0 1 1 2
P1 1 0 0 0 1 7 5 0
P2 1 3 5 4 2 4 5 6
P3 0 4 3 2 0 7 5 2
P4 0 0 1 4 0 6 5 6
Ans:
Need
A B C D
P0 0 1 0 0
P1 0 7 5 0
P2 1 1 0 2
P3 0 3 2 0
P4 0 6 4 2
所以最少 = (3,12,12,12)
这题我尝试过各种算法,
都解不出这个数字呀Q___Q
是要用到定理那两个算式吗? (Maxi <= m , Maxi总合 < n+m这两个...)
请大大解决
谢谢!!!!!!!!!!!!!
--
Why Not :-P
http://whynot-p.blogspot.com/
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 111.248.50.179
※ 编辑: mickeyha 来自: 111.248.50.179 (11/01 23:11)
1F:→ Eggchun:一开始把0420配给P1所以P1的NEED剩下0330,之後看NEED,最小 11/02 00:07
2F:→ Eggchun:是P0(因为他只要1就可以完成),所以就假设目前只剩下0100 11/02 00:10
3F:→ Eggchun:的资源可以给他使用,完成後释出,所以现在有0113的资源, 11/02 00:10
4F:→ Eggchun:因为0113的资源也没有办法配给现在需要资源的process,所以 11/02 00:11
5F:→ Eggchun:再找一次需要最少资源便可完成的process,所以是p2,p2完成 11/02 00:13
6F:→ Eggchun:後,就有2466的资源了,2466每个PROCESS都可以拿,所以只要把 11/02 00:14
7F:→ Eggchun:剩下的PROCESS所占有的资源全部加回,就可以得到3,12,12,12 11/02 00:15
8F:→ Eggchun:我是这样算的啦-.- 不知道有没有其他方式XD? 11/02 00:15