In this slide we are going to know: What is Deadlock? How can we Avoid Deadlock?
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.
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.
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.
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 1 st 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.
In order to determine the condition of next state (safe/ unsafe/ deadlock) the s ystem 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
Presented by: Mohammad Hafiz-Al- Masud , ID: 1209035, Session: 2012/13, Department of ICT, Comilla University.