Deadlocks




Answer & solution
Answer: P2 → P0 → P1 → P3. (no official key was published)
Use the available-vector test in resource order (r1,r2,r3). Initially Work=(0,0,1). P2 requests (0,0,1), so its request fits. On completion its original holding (0,1,0) returns to the available pool, giving Work=(0,1,1). It is important not to count the temporarily granted r3 twice: allocation-based reduction adds only the allocation it held before this simulated completion.
Next P0 requests (0,1,1), exactly within Work. It finishes and releases original allocation (1,0,1), making Work=(1,1,2). P1's outstanding request (1,0,0) now fits; releasing its original allocation (1,1,0) gives Work=(2,2,2). P3 can finally receive (1,2,0); releasing its original holding (0,1,0) gives Work=(2,3,2), the complete resource inventory. Thus P2,P0,P1,P3 is a valid completion sequence.
Indeed the initial choices are forced by the displayed requests: P0 initially lacks r2, while P1 and P3 lack r1. After P2, P0 is the only remaining satisfiable process. After P0, P3 still needs two free r2 instances but only one is available, forcing P1 before P3. Under simultaneous satisfaction of the displayed request vectors this order is therefore unique. As in part (a), “safe” means all these displayed requests can be satisfied and the processes finish; the graph does not state maximum possible future claims, so a stronger Banker's-algorithm safety assertion is outside the supplied data.