GATE / CS ARCHIVE

GATE CSE 2018 / QUESTION 24

Resource bound preventing deadlock

Operating Systems · Deadlocks · Full GATE CSE 2018 paper

GATE 2018, Q24 1 mark · NAT
Report issue

Deadlocks

Question 24, GATE 2018: Three processes share four identical resource instances. Each can need at most K, requesting and releasing one at a time. Find the largest K guaranteeing no deadlock.
Tap to enlarge
Answer & solution

Official answer: 2

Method

If every unfinished process has fewer than its maximum requirement, each may hold at most K−1 while waiting for another instance. With K=2, three such waiting processes can hold at most three resources, leaving the fourth available to let one finish. Releasing its resources then enables the others. For K=3, a feasible allocation (2,1,1) consumes all resources while each process can still request one; no request can be granted. This supplies both safety and a tight counterexample.

Solution

For n=3 processes each requiring at most K identical resources, a sufficient and tight universal bound is R≥n(K−1)+1: for K=2, any allocation in which all three processes still need another instance leaves at least one of the four resources free; for K=3 the allocation (2,1,1) can instead exhaust all resources with all processes waiting. With R=4, K=2 satisfies 4≥4, while K=3 permits holdings2, 1, 1 and all waiting. Thus the largest guaranteed-safe K is 2, assuming completed processes release their resources.

Original paper, page 10 · Answer key