---
# System prepended metadata

title: 第12周

---

# 題目
* 林子皓
Use the Banker algorithm to calculate their completion order

|     | MAX | ALLOCATION | AVAILABLE | NEED |
| --- | --- | ---------- | --------- | ---- |
|     | ABC | ABC        | ABC       | ACB  |
| P1  | 753 | 010        | 332       | 743  |
| P2  | 322 | 200        |           | 122  |
| P3  | 902 | 302        |           | 600  |
| P4  | 222 | 211        |           | 011  |
| P5  | 433 | 002        |           | 431  |


332>112(P2) 332+200=532
532>011(P4) 532+211=743
743>431(P5) 743+002=745
745>743(P1) 745+010=755
755>600(P3) 
ANS:
P2>P4>P5>P1>P3

* 楊秉沅





* 王尚鵬

Please construct the wait-for graph based on the given Resource-Allocation Graph and discuss whether deadlock will happen.
![image](https://hackmd.io/_uploads/B1H-Wv1m1x.png)


Ans:
Deadlock will happen.
![image](https://hackmd.io/_uploads/BkBSvW1mkg.png)





* 楊閔恩
![image](https://hackmd.io/_uploads/ByTSCLk7Jg.png)

Q1. Will the operation result in a deadlock in the diagram above? If so, why? Please explain.

Ans:
(1)Yes
(2)
1. P2 has acquired resources from R1 and R2 but is waiting for R3.
2. R3 is held by P3.
3. P3 is waiting for R2, while one instance of R2 is held by P2 and the other instance is held by P1.
4. P1 is waiting for R1, which is held by P2.
5. At this point, a resource circular wait is formed, and a deadlock occurs.
