GATE / CS ARCHIVE

GATE CSE 2018 / QUESTION 39

A Banker safety sequence

Operating Systems · Deadlocks · Full GATE CSE 2018 paper

GATE 2018, Q39 2 marks · MCQ
Report issue

Deadlocks

Question 39, GATE 2018: Available (E,F,G)=(3,3,0). Allocation rows P0…P3 are (1,0,1),(1,1,2),(1,0,3),(2,0,0); Max rows are (4,3,1),(2,1,4),(1,3,3),(5,4,1). Choose A safe already; B unsafe but safe with one extra E; C likewise extra F; D likewise extra G.
Tap to enlarge
Your answer
Answer & solution

Official answer: A

Step through it (6 steps)

Method

Banker’s safety test asks whether there exists an order in which each process can obtain all its remaining need and release its allocation. Need=Max−Allocation, computed component by component. After hypothetically finishing a process, Work increases by its original Allocation, not by its Max: any temporary extra resources lent from Work are returned, cancelling out. Initially P0 and P2 are both eligible. Exhibiting one complete order suffices; the algorithm need not show that every arbitrary request order is safe.

Solution

Subtract Allocation from Max to obtain remaining needs P0=(3, 3, 0), P1=(1, 0, 2), P2=(0, 3, 0), P3=(3, 4, 1). Starting Work=(3, 3, 0), complete P0 to get(4, 3, 1), then P2 to get(5, 3, 4), then P1 to get(6, 4, 6), then P3. This safe sequence proves A.

Original paper, page 16 · Answer key