GATE / CS ARCHIVE

GATE CSE 2014 SET 1 / QUESTION 31

GATE CSE 2014 Set 1 Q31

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

GATE 2014 Set 1, Q31 2 marks · MCQ
Report issue

Deadlocks

Question 31, GATE 2014: Banker’s algorithm manages resources X,Y,Z for P0,P1,P2. Allocation rows are P0=(0,0,1), P1=(3,2,0), P2=(2,1,1); maximum-demand rows are P0=(8,4,3), P1=(6,2,0), P2=(3,3,3). Available=(3,2,2), and the current state is safe. Consider independent requests: REQ1 P0 asks (0,0,2); REQ2 P1 asks (2,0,0). Which may be granted safely? A: REQ1 only. B: REQ2 only. C: both. D: neither.
Tap to enlarge
Your answer
Answer & solution

Official answer: B

Step through it (2 checks)

1. Method and setup. Compute Need=Max−Allocation. For each request separately, tentatively decrease Available and increase the requester’s Allocation, then try to find a complete safe sequence. Sufficient available resources for the immediate grant is necessary but not sufficient; the updated state must still permit every process to finish.

2. Work through the result and its assumptions. Initial needs are P0=(8, 4, 2), P1=(3, 0, 0), P2=(1, 2, 2). Grant REQ1: available=(3, 2, 0); only P1 can finish, releasing(3, 2, 0) to give(6, 4, 0). Neither remaining process can finish, so unsafe. Grant REQ2: available=(1, 2, 2), P1 need=(1, 0, 0); finish P1 to get(6, 4, 2), then P2 to get(8, 5, 3), then P0. Only REQ2 is safe, B.

Original paper, page 15 · Answer key