Bankers_Algorithm_Solution
Bankers_Algorithm_Solution
--------|------------------
P0 |0000
P1 |0750
P2 |1002
P3 |0020
P4 |0642
1. P0: Need = [0, 0, 0, 0] <= Available = [1, 5, 2, 0] -> Allocate to P0 -> Update Available: [1, 5, 3, 2]
2. P2: Need = [1, 0, 0, 2] <= Available = [1, 5, 3, 2] -> Allocate to P2 -> Update Available: [2, 8, 8, 6]
3. P3: Need = [0, 0, 2, 0] <= Available = [2, 8, 8, 6] -> Allocate to P3 -> Update Available: [2, 14, 11, 8]
4. P4: Need = [0, 6, 4, 2] <= Available = [2, 14, 11, 8] -> Allocate to P4 -> Update Available: [2, 14, 12, 12]
5. P1: Need = [0, 7, 5, 0] <= Available = [2, 14, 12, 12] -> Allocate to P1 -> Update Available: [3, 14, 12, 12]
Conditions to check:
Since both conditions are satisfied, the request can be granted immediately.