CS FundamentalsHardGATE CS (PYQ pattern)

Locks are ordered L1 < L2 < L3 < L4 and every thread must acquire locks in increasing order. A thread acquires locks in the following sequence and releases a lock only where stated: lock L1, lock L3, release L3, lock L2, lock L4, lock L3. At which acquisition does it first violate the ordering rule?

  1. A. The final lock L3 (L4 is held and L3 < L4)
  2. B. lock L2 (L3 was acquired before it)
  3. C. lock L4 (L2 is held)
  4. D. It never violates the rule

Correct answer: A. The final lock L3 (L4 is held and L3 < L4)

After 'release L3' the thread holds only L1, so locking L2 is fine, and L4 is fine (above L2). The last acquisition requests L3 while holding L4, which breaks the increasing-order rule.

More Operating Systems questions

Exams that ask this topic