Question

Consider the following policies for preventing deadlock in a system with mutually exclusive resources:
I. Processes should acquire all their resources at the beginning of execution. If any resource is not available, all resources acquired so far are released.
II. The resources are numbered uniquely, and processes are allowed to request for resources only in increasing resource numbers.
III. The resources are numbered uniquely, and processes are allowed to request for resources only in decreasing resource numbers.
IV. The resources are numbered uniquely. A process is allowed to request only for a resource with resource number larger than its currently held resources.

Which of the above policies can be used for preventing deadlock?

Choose one option
Official answer and solution
Official answer
D
From
Official GATE 2015 answer key

Solution

Evaluate each policy against the Coffman conditions for deadlock prevention.

Deadlock prevention operates by invalidating at least one of the four necessary Coffman conditions:

  1. Mutual Exclusion
  2. Hold and Wait
  3. No Preemption
  4. Circular Wait

Evaluate the four policies:

  • Policy I (Conservative / all-or-nothing): Requesting all resources before execution and releasing all held resources if any is unavailable directly eliminates the Hold-and-Wait condition and allows preemption. It prevents deadlock.
  • Policy II (Global Linear Ordering): Numbering resources uniquely and allowing requests only in increasing order prevents Circular Wait, because no cycle can exist in a directed graph where edges always point from lower numbers to higher numbers. It prevents deadlock.
  • Policy III (Global Linear Ordering): Allowing requests only in decreasing order also establishes a strict linear ordering, which symmetrically eliminates Circular Wait. It prevents deadlock.
  • Policy IV (Monotonic Request Ordering): A process may only request resources strictly greater than any resource it currently holds. This is the standard hierarchical resource ordering policy that eliminates Circular Wait. It prevents deadlock.

Thus, any one of I, II, III, and IV can be used for preventing deadlock (Option D).

Final answer

D

Common trap

Believing only increasing resource order prevents deadlock, whereas any strict global linear ordering (increasing or decreasing) prevents circular wait.

The answer is the one in the official GATE answer key. The solution is this site's own explanation.

Source

Paper
GATE 2015 Computer Science and Information Technology (CS) Session 3
Question
62 of 65, printed as CS Q.52
Section
Computer Science and Information Technology

Report an error in this question

GATE questions are the work of the organising institutes. This site is independent and is not affiliated with them.