- GATE CS
- 2026–27 pattern practice
- Operating Systems
- Deadlocks
- Medium
A system has 10 units of one resource. Processes P1, P2 and P3 hold 3, 2 and 2 units and have maximum needs of 7, 4 and 9 units. Which sequence is safe under the Banker's algorithm?
Process Management
Pick an option to check your answer.
Answer: A. Solution
Free units = . Remaining needs are P1: 4, P2: 2, P3: 7. P2 can run (2 ≤ 3) and then returns its 2, leaving 5 free. P1 can then run (4 ≤ 5) and returns 3, leaving 8. P3 finally runs (7 ≤ 8). So P2, P1, P3 is safe.
Why not the others
- P1, P2, P3 fails at the start: P1 still needs 4 units but only 3 are free.
- P3, P2, P1 fails at the start: P3 still needs 7 units but only 3 are free.
- P2, P3, P1 fails at the second step: after P2 finishes 5 units are free, but P3 needs 7.