what is deadlock in os

what is deadlock in os

1 year ago 34
Nature

Deadlock is a situation in which two or more processes are blocked because each process is holding a resource and waiting for another resource acquired by some other process. In other words, it is a state where each process is waiting for a resource that is being held by another process, and neither process can proceed until the other releases the resource. Deadlocks can occur in operating systems when four necessary conditions hold simultaneously:

  • Mutual Exclusion: At least one resource is held in a non-shareable mode. Only one process can use the resource at any given time.
  • Hold and Wait: A process is holding at least one resource and waiting for another resource.
  • No Preemption: A resource cannot be taken from a process unless the process releases the resource.
  • Circular Wait: A set of processes is waiting for each other in a circular chain.

There are different methods of handling deadlocks, including deadlock avoidance, deadlock prevention, deadline detection and recovery, and deadlock ignorance. Deadlock avoidance involves preventing any one of the four necessary conditions for a deadlock. Deadlock prevention involves ensuring that at least one of the four necessary conditions does not hold. Deadline detection and recovery involves detecting deadlocks and taking corrective action. Deadlock ignorance involves ignoring the problem of deadlock and assuming that it never occurs.

Read Entire Article