Deadlock Avoidance Example
Allocation Max Available
A B C A B C A B C
P0 0 1 0 7 5 3 3 3 2
P1 2 0 0 3 2 2
P2 3 0 2 9 0 2
P3 2 1 1 2 2 2
P4 0 0 2 4 3 3
Allocation Need Available
A B C A B C A B C
P0 0 1 0 7 4 3 3 3 2
P1 2 0 0 1 2 2
P2 3 0 2 6 0 0
P3 2 1 1 0 1 1
P4 0 0 2 4 3 1
Processes can finish in order < P1, P3, P4, P2, P0 > so system is in a safe state.
Can a request by P1 for (1, 0, 2) be granted?
To determine this, first update table assuming new request has been granted:
Allocation Need Available
A B C A B C A B C
P0 0 1 0 7 4 3 2 3 0
P1 3 0 2 0 2 0
P2 3 0 2 6 0 0
P3 2 1 1 0 1 1
P4 0 0 2 4 3 1
Second, see if there is an order where processes can finish. Yes there is:
< P1, P3, P4, P0, P2 >
Can a request by P4 for (3, 3, 0) be granted?
Can a request by P0 for (0, 2, 0) be granted?