GATE / CS ARCHIVE

GATE CSE 2017 SET 1 / QUESTION 27

GATE CSE 2017 Set 1 Q27

Operating Systems · Deadlocks · Full GATE CSE 2017 Set 1 paper

GATE 2017 Set 1, Q27 2 marks · MCQ
Report issue

Deadlocks

Question 27, GATE 2017: A program has x threads and y non-reentrant locks. A thread cannot reacquire a lock it holds, and blocks if acquisition fails. Find minimum x,y allowing deadlock. A (1,2); B (2,1); C (2,2); D (1,1).
Tap to enlarge
Your answer
Answer & solution

Official answer: D

1. Consider a single thread and one initially free non-reentrant lock L. The thread acquires L successfully.

2. Before releasing L, let the same thread request L again. The non-reentrancy rule blocks it because L is already held, even though the holder is itself.

3. Only this blocked thread could release L, so it cannot progress: self-deadlock. At least one thread and one lock are needed to discuss this failure, and this example achieves both minima. Answer D.

Original paper, page 13 · Answer key