Lab
Banker's algorithm lab
Edit the matrices, see Need and the safe sequence, and test whether a request can be granted.
The state of the system
Allocation, maximum claim and what is free
Allocation
| A | B | C | |
|---|---|---|---|
| P0 | |||
| P1 | |||
| P2 | |||
| P3 | |||
| P4 |
Maximum
| A | B | C | |
|---|---|---|---|
| P0 | |||
| P1 | |||
| P2 | |||
| P3 | |||
| P4 |
Available
| A | B | C | |
|---|---|---|---|
| P0 |
Try
Is it safe?
Safe: an order exists
Need = Maximum − Allocation
| Process | A | B | C |
|---|---|---|---|
| P0 | 7 | 4 | 3 |
| P1 | 1 | 2 | 2 |
| P2 | 6 | 0 | 0 |
| P3 | 0 | 1 | 1 |
| P4 | 4 | 3 | 1 |
Safe sequence: P1 → P3 → P0 → P2 → P4
- P1 needs 1 2 2, which fits. When it finishes it returns 2 0 0, so free becomes 5 3 2.
- P3 needs 0 1 1, which fits. When it finishes it returns 2 1 1, so free becomes 7 4 3.
- P0 needs 7 4 3, which fits. When it finishes it returns 0 1 0, so free becomes 7 5 3.
- P2 needs 6 0 0, which fits. When it finishes it returns 3 0 2, so free becomes 10 5 5.
- P4 needs 4 3 1, which fits. When it finishes it returns 0 0 2, so free becomes 10 5 7.
Can a request be granted?
Check it against the need, what is free, and safety