CS FundamentalsModerateGATE CS · Amazon/Microsoft SDE MCQ

Two threads acquire mutexes: T1 locks A then B; T2 locks B then A. Which change prevents deadlock while still letting both threads hold both locks when needed?

  1. A. Make both threads lock A before B
  2. B. Make B a recursive (reentrant) mutex
  3. C. Give T1 a higher priority than T2
  4. D. Unlock A before locking B in T1 only

Correct answer: A. Make both threads lock A before B

A fixed global acquisition order removes circular wait, one of the four necessary conditions. Recursive mutexes and priorities do nothing about the cycle; releasing A first changes the semantics because T1 no longer holds both.

More Operating Systems questions

Exams that ask this topic