Solution:
Step 1: Calculate Need Matrix
Need = Max − Allocation
Process Need
(A B C D)
P0 (0 0 0 0)
P1 (0 7 5 0)
P2 (1 0 0 2)
P3 (0 0 2 0)
P4 (0 6 4 2)
Step 2: Available Resources
Initially Available = (1 5 2 0)
Step 3: Check each process ( NOTE : Always select the next process whose Need ≤ Available. )
• P0: Need (0 0 0 0) ≤ Available → P0 can execute.
• After P0, Available becomes (1 5 3 2).
• P2: Need (1 0 0 2) ≤ Available → P2 can execute.
• After P2, Available becomes (2 8 8 6).
• P1: Need (0 7 5 0) ≤ Available → P1 can execute.
• After P1, Available becomes (3 8 8 6).
• P3: Need (0 0 2 0) ≤ Available → P3 can execute.
• After P3, Available becomes (3 14 11 8).
• P4: Need (0 6 4 2) ≤ Available → P4 can execute.
• After P4, Available becomes (3 14 12 12).
Hence, all processes can execute safely.
Final Answer:
System is SAFE.
Safe Sequence = (P0 → P2 → P1 → P3 → P4)
There is NO Deadlock in this system.