Banker's Algorithm - Important Numerical
Questions with Solutions
Question 1: Given Allocation, Max and Available resources, determine safe sequence.
Allocation: P0(0,1,0), P1(2,0,0), P2(3,0,2)
Max: P0(7,5,3), P1(3,2,2), P2(9,0,2)
Available: (3,3,2)
Solution: Need = Max - Allocation. Compute need and check safe sequence step by step.
Need: P0(7,4,3), P1(1,2,2), P2(6,0,0)
Safe sequence: P1 → P2 → P0
Question 2: Check if system is in safe state.
Allocation: P0(1,0,1), P1(2,1,0)
Max: P0(3,2,1), P1(2,2,2)
Available: (1,1,1)
Solution: Need = Max - Allocation
Need: P0(2,2,0), P1(0,1,2)
System is safe: P1 → P0
Question 3: Check if request can be granted.
Process P1 requests (1,0,2)
Check: Request ≤ Need and Request ≤ Available
Then simulate allocation and check safe state.
If safe → Grant, else → Wait