Try   HackMD

Deadlock Detection

Deadlock Detection

  • 系統必須提供一個演算法去檢視是否有deadlock發生
  • 需要一個演算法來回復deadlock

single instance

  • 當有cycle的時候會發生deadlock
  • an edge from Pi to Pj 代表 Pi 在等 Pj 釋放一個 Pi 需要的資源
  • 圖(b)叫做 wait-for graph

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 →

several instance

  • data structure
    • Available
    • Allocation
    • Request
      • n×m
        matrix
      • Request[i, j] = k 代表Pi 正請求k個Rj
  1. Initialize

    ​​​​Work = Available;
    ​​​​for (i = 1; i <= n; i++)
    ​​​​    if (Allocation[i] != 0)
    ​​​​        Finish[i] = false;
    ​​​​    Finish[i] = true;
    
  2. Find an index i

    • Finish[i] == false&& Requesti ≤ Work
    • 如果 i 不存在,跳到4
  3. 可以執行

    • Work = Work + Allocation[i] process釋放資源
    • Finish[i] = true 工作完成
    • 回到2
  4. If Finish[i] == false , for some i, 1 ≤ i ≤ n, then the system is in deadlock state

    • Finish[i] == false → Pi is deadlocked

last edit

dotTue, Jul 28, 2020 11:04 PM

HOME PAGE :dart:

tags: OS CSIE