Handling DeadLocks

 Handling Deadlocks


Whenever a deadlock occurs the deadlock must be handled. It can be handled by three fundamental approaches:

  1. Deadlock detection and resolution
  2. Deadlock prevention
  3. Deadlock avoidance

Deadlock detection and Resolution:  The kernel analyzes the resource state to check whether a deadlock exists. If it exists it aborts some processes and allocates the resources held to them to other processes so that the deadlock comes to an end.




Deadlock Prevention: The kernel uses an allocation policy that ensures that the four conditions for resource deadlocks do not arise simultaneously. It makes deadlock impossible.




Deadlock avoidance: The kernel analyzes the allocation state to determine whether granting a resource request can lead to a deadlock in the future. Only requests that cannot lead to deadlock are granted.
Thus, deadlocks do not arise