GATE / CS ARCHIVE

GATE CSE 2021 SET 2 / QUESTION 43

GATE CSE 2021 Set 2 Q43

Operating Systems · Deadlocks · Full GATE CSE 2021 Set 2 paper

GATE 2021 Set 2, Q43 2 marks · MSQ
Report issue

Deadlocks

Question 43, GATE 2021: One instance per resource type, exclusive ownership. OWNRESOURCE(R) acquires global lock L; if free, acquire R and release L; else if owned by another P, terminate P after freeing its resources, acquire R, restart P, release L. Select: A prevents deadlocks; B may livelock; C may starve; D violates mutual exclusion.
Tap to enlarge
Select all that apply
Answer & solution

Official answer: A; B; C

Under the intended atomic termination/resource-release model, a requester never waits for another process to release its resource: it terminates that owner and takes the resource while holding L. Thus no circular resource wait develops, giving A. Two restarted processes can repeatedly take resources from and restart each other without completing, giving livelock B. An unfair execution can repeatedly kill the same process before it finishes, giving starvation C. The global lock and removal of the previous owner preserve exclusive ownership, so D is false. This assumes requests concern resources not already owned by the requester and that termination/restart do not themselves block on L; those implementation details are abstracted by the pseudocode.

For a livelock witness, let P hold A and Q hold B. P requests B, kills and restarts Q; later restarted Q requests a resource now held by P and kills/restarts P. Repeating such interference can prevent either from completing despite activity. A lock provides mutual exclusion, not fairness or progress. The answer depends on treating termination and resource release as atomic successful operations in the model.

Original paper, page 80 · Answer key