AI InterviewSearch…Search problems, topics, or pages…Ctrl KGet started
Mediumdeadlockprevention

~90s

Numbering the resources

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?

Show the answer and the worked solution

Correct answer: A.

Circular wait

Worked solution

  1. A deadlock cycle needs at least one process holding a higher-numbered resource while waiting for a lower-numbered one.
  2. The ordering rule forbids exactly that request, so that edge can never appear in the wait-for graph.
  3. 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.

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.

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

  1. Circular wait
  2. Hold and wait
  3. Mutual exclusion
  4. No preemption
Show the answer and the worked solution

Correct answer: A. Circular wait

Worked solution

  1. A deadlock cycle needs at least one process holding a higher-numbered resource while waiting for a lower-numbered one.
  2. The ordering rule forbids exactly that request, so that edge can never appear in the wait-for graph.
  3. 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.

All OS, DBMS & Networks questions · placement mock tests