Similar questions 1 more →
Deadlocks


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.