0% found this document useful (0 votes)
66 views8 pages

Deadlock 4

The document discusses different strategies for dealing with deadlocks: detection and recovery, avoidance, and prevention. It explains the concepts of safe and unsafe states, where a safe state is one where all processes can complete and an unsafe state is where deadlock is possible. As an example, it shows a state that transitions from safe to unsafe when a new resource allocation is made. Finally, it introduces the Banker's Algorithm method for deadlock avoidance by checking if new requests would lead to a safe state before granting resources.

Uploaded by

safina mirza
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
66 views8 pages

Deadlock 4

The document discusses different strategies for dealing with deadlocks: detection and recovery, avoidance, and prevention. It explains the concepts of safe and unsafe states, where a safe state is one where all processes can complete and an unsafe state is where deadlock is possible. As an example, it shows a state that transitions from safe to unsafe when a new resource allocation is made. Finally, it introduces the Banker's Algorithm method for deadlock avoidance by checking if new requests would lead to a safe state before granting resources.

Uploaded by

safina mirza
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 8

discover yourself

inspire posterity

DEADLOCKS
Lecture 14

06/04/2020 1
discover yourself
inspire posterity

Deadlock Strategies

1. Detection and Recovery: Let deadlocks occur,


detect them and take action.
2. Deadlock avoidance by carefully resource
allocation.
3. Prevention: Negating one of the four
conditions necessary to cause a deadlock.

06/04/2020 2
discover yourself
inspire posterity

Safe State

Total Resources=10

3 4/6/2020
4/6/2020 3
discover yourself
inspire posterity

Unsafe State

A state is said to be Un-safe if it is deadlocked and there is


some scheduling order in which every process cannot run
to completion.
OR
Un-safe state is that in which system cannot guarantee that
all processes will finish.
4 4/6/2020
4/6/2020 4
discover yourself
inspire posterity

CONCLUSION

1. Thus the allocation decision that moved the system from (a) to
(b) went from a safe state to an unsafe state.

2. It means A’s request should not have been granted.

3. It is worth noting that an unsafe state is not a deadlock state


because it is possible that A might release a resource before
asking for any more resource, allowing C to complete and
avoiding deadlock altogether.

5 4/6/2020
4/6/2020 5
discover yourself
inspire posterity

EXAMPLE of Safe & Un-Safe States

6 4/6/2020
4/6/2020 6
discover yourself
inspire posterity

Deadlock-Avoidance
Banker’s Algorithm for a Single Resource

Banker’s algorithm considers each request as it


occurs, and see if granting it leads to a safe state,
if it does, the request is granted otherwise denied.

7 4/6/2020
4/6/2020 7
discover yourself
inspire posterity
Banker’s Algorithm for a Single Resource
Banker’s algorithm is used to check which state is safe and un-safe.

This state is safe because with 2 resources left the process can delay any
requests except C’s, thus letting C finish and release all four of its
resources. With four resources in hand, the process can let either D or B
have the necessary resources and so on.

8 4/6/2020
4/6/2020 8

You might also like