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?
- A. Make both threads lock A before B
- B. Make B a recursive (reentrant) mutex
- C. Give T1 a higher priority than T2
- 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
- A system uses demand paging with a 4 KB page, and a process allocates a fresh 1 MB zeroed buffer with mmap but touches only its first 10…
- Which statement about a system call compared with an ordinary function call is correct?
- Five batch jobs arrive together with run times 9, 6, 3, 5 and x, where x < 3. In what order should they run to minimise average turnaround…
- Statement 1: Under round robin, as the quantum shrinks towards the context-switch time, CPU efficiency approaches 50%. Statement 2: For a…
- Which of these must a process NOT be able to do in user mode on a typical protected OS?
- A process's working set grows from 40 to 70 pages while it holds 50 frames under local replacement, and the system has 10 free frames…