Examples of safe and unsafe systems: process max needs cur alloc needs left free
P0 10 5 5 3
P1 4 2 2
P2 9 2 7
There's one resource type (tape drives) with twelve instances, allocated as shown. The processes have the indicated max possible needs and remaining needs. The system shown above is safe. {P1, P0, P2} is a safe sequence - the processes could finish executing in that order, even if all the processes first request all of their remaining needs. However, suppose that, starting from the situation depicted in the table above, P2 requests and is given one more tape drive. Then the state changes to this one:process max needs cur alloc needs left free
P0 10 5 5 2
P1 4 2 2
P2 9 3 6
This system is unsafe. If all the processes request their remaining needs, the system will be deadlocked. It will be possible for the OS to give P1 its remaining needs, and possible for P1 to finish and exit. However, after that there will be only 4 tape drives free, and so both P0 and P2 will be kept waiting forever.