2. In this slide we are going to
know:
What is Deadlock?
How can we Avoid Deadlock?
3. What is Deadlock?
A deadlock is a situation which occurs when a process enters in a waiting state
because 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
being used by another waiting process, then the system is said to be in a deadlock.
4. A practical example of Deadlock
You can't get a job without experience. You can't get experience without a job.
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 resource at the
same time as the second process locks the second resource.
(D) The deadlock can be resolved by cancelling and restarting the first
process.
5. Deadlock Avoidance
Deadlock can be avoided if certain information about processes
are available to the operating system before allocation of resources.
For every resource 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.
6. Possible States
Deadlock: No further progress is possible.
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.
7. 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 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.
THE END