CS FundamentalsVery hardProduct company interview · GATE level

A system with resource types A, B, C (several instances each) runs the deadlock-detection algorithm. Allocation: P0 (0,1,0), P1 (2,0,0), P2 (3,0,3), P3 (2,1,1), P4 (0,0,2). Current requests: P0 (0,0,0), P1 (2,0,2), P2 (0,0,1), P3 (1,0,0), P4 (0,0,2). Which processes are deadlocked if Available is (0,0,0), and which if Available is (0,0,1)?

  1. A. (0,0,0): P1, P2, P3 and P4; (0,0,1): none
  2. B. (0,0,0): none; (0,0,1): none
  3. C. (0,0,0): P1, P2, P3 and P4; (0,0,1): P1 only
  4. D. (0,0,0): P1 and P2 only; (0,0,1): none

Correct answer: A. (0,0,0): P1, P2, P3 and P4; (0,0,1): none

Detection treats current requests like needs. With (0,0,0) only P0 (requesting nothing) can finish; it returns (0,1,0), which satisfies none of the others, so P1-P4 are deadlocked. With (0,0,1), P0 finishes (work (0,1,1)), then P2 (request (0,0,1)) finishes and returns (3,0,3) for (3,1,4); now P3 and P4 finish, and finally P1 (2,0,2). One spare instance of C breaks the whole deadlock, so stopping after the first pass and declaring P1 deadlocked is wrong.

More Operating Systems questions

Exams that ask this topic