GATE / CS ARCHIVE

SIMILAR QUESTIONS / OPERATING SYSTEMS

Test requests by tentative Banker allocation

2 questions solved the same way, newest first. Back to Operating Systems

How these are solved

For each proposed request independently, check claim/availability, tentatively update allocation and available vectors, then perform the safety reduction. The candidate requests and initial matrices differ.

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

Descriptive
Report issue

Testing a Banker resource request

Deadlocks

Question 22(b), GATE 1996: Three processes P0,P1,P2 share resource types R0,R1,R2. Maximum total claims are P0=(4,1,2), P1=(1,5,1), P2=(1,2,3). Current allocations are P0=(1,0,2), P1=(0,3,1), P2=(1,0,2), and Available=(2,2,0). Determine what happens when P0 requests one unit of R1.
Question 22(b), GATE 1996: Three processes P0,P1,P2 share resource types R0,R1,R2. Maximum total claims are P0=(4,1,2), P1=(1,5,1), P2=(1,2,3). Current allocations are P0=(1,0,2), P1=(0,3,1), P2=(1,0,2), and Available=(2,2,0). Determine what happens when P0 requests one unit of R1.
Tap to enlarge
Answer & solution

Answer: Defer P0’s request: tentative Available=(2,1,0) is unsafe although the unit is available. (no official key was published)

Step through it (4 steps)

The request vector is R=(0,1,0). First check R<=Need0=(3,1,0), so the request does not exceed P0's remaining claim. Also R<=Available=(2,2,0), so the requested unit is physically available. These necessary checks alone do not justify granting it.

Tentatively allocate the unit. Available becomes (2,1,0), P0's allocation becomes (1,1,2), and P0's remaining need becomes (3,0,0). The other needs remain P1=(1,2,0), P2=(0,2,1). Begin the safety test with Work=(2,1,0). P0 cannot finish because 3>2 in R0; P1 cannot finish because 2>1 in R1; P2 cannot finish because it needs 2 R1 and 1 R2, while only 1 R1 and 0 R2 are free. No process can be the first in a guaranteed completion sequence.

The tentative state is therefore unsafe. The Banker rolls back the tentative change and makes P0 wait, preserving Available=(2,2,0) and the original safe allocations. This is not a claim that the request is invalid or that an actual deadlock has already occurred. It is a refusal to enter a state from which completion under all declared maximum claims cannot be guaranteed. The one free unit's availability is precisely why a full safety test, rather than a simple availability check, is needed.

Original paper, page 10