Deadlock avoidance
Deadlock avoidance
- 可以利用演算法避免deadlock
- safe state
- a save sequence {P1, P2, …, Pn}
- Pi最多可以請求的資源數 = available resources + resources held by all Pj , with j < i
- unsafe state
- may lead to a deadlock
- not all unsafe states are deadlocks
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
Resource-Allocation-Graph Algorithm
-
For one instance of each resource type only
-
A direct edge from Pi → Rj is called a request edge
-
A direct edge from Rj → Pi is called a assignment edge
-
claim edge
- Pi → Rj 代表 Pi 未來某個時間點可以請求 Rj
- 虛線表示
- 當Pi請求Rj,Pi → Rj會轉換成request edge(實線)
- 當Pi釋放Rj, assignment edge Rj → Pi 會轉換成claim edge
-
Pi 開始執行之前,所有的claim edge都要出現在圖上
-
如果edge的方向轉換後會造成cycle,就不能讓請求成立
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
Banker's Algorithm
Safety algorithm
-
Initialize
- Let Work and Finish be vectors of length m and n
Work = Available
Finish[i] = false
, i = 0, 1, …, n-1
-
Find an i
Finish[i] = false
&& Needi ≤ Work
- 如果i不存在,跳到4
-
可以執行
Work = Work + Allocation[i]
process釋放資源
Finish[i] = true
工作完成
- 回到2
-
如果 Finish
中全部都是 true,代表系統現在是 safe state
Resource-request algorithm
- 用來決定一個新的請求是不是safe,如果是safe就讓它執行
-
If Requesti ≤ Needi go to step 2
- Requesti不能比Needi大,否則會超過Pi最多可請求的資源數
-
If Requesti ≤ Availablei go to step 3
-
- 可用資源被該process請求資源扣掉
- 該process所佔有的資源增加
- 該process還需要的資源減少
- 如果結果是safe → 把資源給Pi
- 如果結果是unsafe → wait
last edit
dotTue, Jul 28, 2020 10:38 PM
HOME PAGE
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →