Numbering the resources — Aptitude Question
Numbering the resources: An operating system numbers every resource and insists that a process request resources… Answer and worked solution on CodeKairo.
- Topic: OS, DBMS & Networks
- Section: Programming MCQs
- Difficulty: Medium
- Time target: 90 seconds
Question
An operating system numbers every resource and insists that a process request resources only in increasing order of number. Which deadlock condition does this rule break?
Options
- Circular wait
- Hold and wait
- Mutual exclusion
- No preemption
Show the answer and the worked solution
Correct answer: A. Circular wait
Worked solution
- A deadlock cycle needs at least one process holding a higher-numbered resource while waiting for a lower-numbered one.
- The ordering rule forbids exactly that request, so that edge can never appear in the wait-for graph.
- Without it the cycle cannot close, which eliminates Circular wait. Processes still hold resources while waiting, resources are still non-preemptable and mutual exclusion is untouched.
Answer: Circular wait.
The idea
Total ordering of resources is the cheapest practical deadlock prevention and is why lock hierarchies are a standard rule in multithreaded code.
Shortcut. A cycle needs someone holding a higher number while requesting a lower one; increasing-order requests make every wait point upwards, so no cycle can close.
Common trap. "Hold and wait" tempts because the rule restricts requests, but processes still hold lower-numbered resources while waiting for higher ones.