GATE / CS ARCHIVE

GATE CSE 2017 SET 2 / QUESTION 33

GATE CSE 2017 Set 2 Q33

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

GATE 2017 Set 2, Q33 2 marks · MCQ
Report issue

Deadlocks

Question 33, GATE 2017: A system has 9 tape drives. Processes (current allocation,maximum requirement) are P1:(3,7), P2:(1,6), P3:(3,5). Classify the state. A:safe,deadlocked. B:safe,not deadlocked. C:not safe,deadlocked. D:not safe,not deadlocked.
Tap to enlarge
Your answer
Answer & solution

Official answer: B

Step through it (5 steps)

1. Current allocations total 3+1+3=7, leaving 9-7=2 drives available. Remaining maximum needs are P1:7-3=4, P2:6-1=5, P3:5-3=2.

2. P3 can receive its remaining two drives and finish. It then returns all five drives, leaving five available to the other processes. Equivalently, in the safety simulation add its existing allocation 3 to the current available count 2.

3. Now P1 can finish and release its three previously allocated drives, raising available to 8; P2 can then finish. Thus P3,P1,P2 is a safe sequence (P3,P2,P1 also works). Existence of a safe sequence establishes safe and not deadlocked, B.

Original paper, page 13 · Answer key