CS FundamentalsVery hardProduct company interview · GATE level

A lock manager grants a request whenever it is compatible with the locks currently held; otherwise the requester waits. The requests arrive in this order: T1 exclusive on A (granted); T2 exclusive on B (granted); T3 shared on C (granted); T1 shared on B; T2 exclusive on C; T4 shared on C; T3 exclusive on A; T4 shared on A. Which statement about the resulting wait-for graph is correct?

  1. A. It has two cycles; aborting T3 alone does not clear the deadlock, but aborting T2 alone does
  2. B. It has one cycle, T1 → T2 → T3 → T1; aborting any one of these three clears the deadlock
  3. C. It has two cycles; aborting T4 alone clears the deadlock
  4. D. It has no cycle, because T4's shared lock on C is compatible with T3's

Correct answer: A. It has two cycles; aborting T3 alone does not clear the deadlock, but aborting T2 alone does

T1 waits for T2 (B). T2's exclusive request on C conflicts with T3's shared lock, so T2 waits for T3. T4's shared request on C is compatible with the lock actually held (T3's shared lock), so it is granted - and now T2 waits for T4 as well. T3 waits for T1 (A) and T4 waits for T1 (A). Edges: T1 → T2, T2 → T3, T2 → T4, T3 → T1, T4 → T1, giving the cycles T1 → T2 → T3 → T1 and T1 → T2 → T4 → T1. Aborting T3 or T4 breaks only one cycle; aborting T1 or T2, which lie on both, clears the deadlock.

More DBMS and SQL questions

Exams that ask this topic