CS FundamentalsVery hardGATE CS (PYQ pattern)

A system has R identical units of one resource. Four processes need at most 3, 4, 2 and 5 units. Each process requests units TWO at a time (granted atomically or not at all), except that its final request is for 1 unit when only 1 more is needed; it holds what it has while waiting and releases everything when done. What is the largest R for which a deadlock is still possible?

  1. A. 10
  2. B. 8
  3. C. 9
  4. D. 7

Correct answer: B. 8

A deadlock needs every unfinished process blocked: its next request (2, or 1 if one unit short) exceeds the free units. Max holdings while unfinished are 2, 2, 0, 4 (sum 8). With all of them held, the 3- and 5-unit processes need only 1 more, so free must be 0: R = 8. To leave 1 unit free, no process may be one short, which caps holdings at 0, 2, 0, 2 = 4 (R = 5). So deadlock is possible up to R = 8; the one-unit-at-a-time formula sum(m - 1) = 10 does not apply here.

More Operating Systems questions

Exams that ask this topic