5,890 views
8 votes
8 votes
Why unsafe state not leads to deadlock?

Please don't redirect to any other link. Explain it by taking an example.

1 Answer

Best answer
9 votes
9 votes
Process Allocated Required Available
  A Printer A Printer A Printer
P1 2 2 2 0 1 0
P2 1 0 1 2

Suppose this is the Current scenario, Here currently no safe sequence exist i.e system is in unsafe state. Here A and Printer are two independent task.

Case 1: Unsafe state not lead to deadlock

Suppose after 30 sec P1 realize he doesn't need printer, so he release all the resources he holds for printer, so now available resources is (1, 2). Now we can fulfill resource request for process P2, and wait for P2 to complete its execution. When P2  completes its execution, it freed up all the resources. So available resources now is (2,2). Now we Can fulfill the demand of P1 as well. 
So we end up getting a safe sequence i.e P2 P1. This happens because P1 release some of its resources.

Case 2: Unsafe State lead to deadlock

Suppose Process P1 request for resource, Now Available resource is (0,0). P1 still need (1,0) and P2 still need (1,2). So in this case even if P1 release some resources, we can't save ourself from deadlock.

So, in general, we can say Unsafe state may lead to deadlock, but this is not always the case.

selected by

Related questions

0 votes
0 votes
1 answer
1
Shubhanshu asked Dec 2, 2017
1,531 views
Consider a system with 12 tape drives with:ProcessMax Need AllocatedP1105P293Is this system is in a safe or unsafe state? If it is not safe then under which condition sys...
0 votes
0 votes
1 answer
2
3 votes
3 votes
3 answers
4
radha gogia asked Oct 14, 2015
820 views
I got the state to be unsafe since Available is (1,1) which can't satisfy the need of any process so why is not deadlock ?