Re: [理工] [OS] unsafe state
: suppose that there are 10 copies of a single resource type
: the resource allocation state is that process A has 1 copy,
: process B has 1 copy,
: process C has 2 copies
: process D has 4 copies
: if we know that the maximum numbers of copies that processes A,B,C,D
: may request are 6,5,4,7 respectively
: now, if we grant process B one more copy, the system enters a X state
: if, instead, we grant process D one more copy, the system enter a Y state
: 答案 (X, Y) = (unsafe, unsafe)
: 請問這題要怎麼算呀?
: 謝謝
process A,B,C,D 最多需求資源分別為 6,5,4,7個
已分配給process A,B,C,D 的資源分別為 1,1,2,4個
所以process A,B,C,D 分別還需要 5,4,2,3個資源才有辦法完成工作
而資源共有10個,已分配掉1+1+2+4 = 8個,所以系統內只剩2個資源可供分配
題目(1) 再分配1個資源給B,則系統內只剩1個資源可供分配,無論接下來是分配給哪個
prosess皆無法使其完成工作,所以系統會進入死結,所以是unsafe state
題目(2) unsafe的原因同題目(1)
補充:此題只有將剩餘的2個資源都分配給process C ,系統才會是safe state
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 118.171.29.15
※ 編輯: leewin 來自: 118.171.29.15 (04/14 19:44)
推
04/14 19:58, , 1F
04/14 19:58, 1F
推
04/15 14:14, , 2F
04/15 14:14, 2F