Safe State in operating systems

What is a state?

State of the system informs that if resources are allocated to different processes then system undergoes deadlock or not.

What is a safe state?

If the system can allocate resources to the process in such a way that it can avoid deadlock. Then the system is in a safe state.

What is the unsafe state?

If the system can’t allocate resources to the process in such a way that it can avoid deadlock. Then the system is in the safe state.

Example:

Free resources : 3

PROCESS Allocated R Needed resources
P1 4 10
P2 2 4
P3 2 7

 

Free resources: 1

PROCESS Allocated R Needed resources
P1 4 10
P2 4 4
P3 2 7
[quads id=1]

Free resources: 5

PROCESS Allocated R Needed resources
P1 4 10
P2 0 0
P3 2 7

 

Free resources : 0

PROCESS Allocated R Needed resources
P1 4 10
P2 0 0
P3 7 7

 

Free resources: 7

PROCESS Allocated R Needed resources
P1 4 10
P2 0 0
P3 0 0

 

Free resources: 1

PROCESS Allocated R Needed resources
P1 10 10
P2 0 0
P3 0 0

 

Free resources: 11

PROCESS Allocated R Needed resources
P1 0 0
P2 0 0
P3 0 0

Result: All processes execute successfully, so there is no deadlock and the system is in the safe state.

Fazal Rehman Shamil
Welcome to all friends. The reason for our success is only your love for T4Tutorials. Our team is always available to answer your queries regarding any kind of confusions or discussion regarding your study and career matters. For discussion with us please join our facebook group "T4Tutorials.com". The link of the group is mentioned below. Thanks and love to all for connecting with us. We are nothing without you. Love you all.....
https://web.facebook.com/groups/2066136233601097/

Leave a Reply