You are on page 1of 10

DEADLOCK

AVOIDANCE

PRESENTED BY : VIGNESH NANDAN


INDEX
1 WHAT IS DEADLOCK?

2 DEADLOCK AVOIDANCE

3 CONCLUSION
DEADLOCK

A deadlock is a situation which occurs when a process enters in a waiting state be-
cause the requested resource is being held by another waiting process, which in
turn is waiting for another resource held by another waiting process. If a process is
unable to change its state indefinitely because the resources requested by it are be-
ing used by another waiting process, then the system is said to be in a deadlock.
PRACTICAL EXAMPLE OF DEADLOCK

LET’S VISUALIZE DEADLOCK


Two processes competing for two resources in opposite order.

(A) A single process goes through.


(B) The later process has to wait.
(C) A deadlock occurs when the first process locks the first resources at
the same thing as the second process locks the second resource.

(D)The deadlock can be resolved by cancelling and restarting the first


process.
DEADLOCK AVOIDANCE

 Deadlock can be avoided if certain information about the processes are


available to the operating system before allocation of resources.
For every request , the system sees whether granting the request will
cause the system to enter an unsafe state that means this state could
result in deadlock.
The system then only grants the requests that will lead to safe states .
Safe, Unsafe, Deadlock State
 Unsafe State: A state that may allow deadlock. It is
possible for a process to be in an unsafe state but
for this not to result in a deadlock.

 Safe State: A state is safe if it has a bunch of


processes and there are enough resources for the
1st process to be finished and after it releases it's
resources there are enough resources for the next
process to be proceed. There is no chance of
Deadlock.
Avoidance algorithms

1.Single instance of a resource type


>Use a resource-allocation graph.

2. Multiple instances of a resource type


>Use the banker’s algorithm.
BASIC FACTS

If a system is in safe state ⇒ no deadlocks.


If a system is in unsafe state ⇒ possibility of deadlock.
Avoidance ⇒ ensure that a system will never enter an unsafe
state.
THE END
In order to determine the condition of next state
(safe/unsafe/deadlock) the system must know these
information in advance

 Resources currently available.


 Resources currently allocated to each process.
 Resources that will be required and released by
CONCLUSION
these processes in the future.

To avoid deadlock we have to follow a simple rule. If a


request causes the next state into unsafe mood or
deadlock then we shouldn’t proceed the request
Thank you
References: https://www.slideshare.net/HafizAlMasudOvi/deadlock-avoidance-in-operating-system
, chatgpt

You might also like