Causes (Conditions) of Deadlock

Filter Course


Causes (Conditions) of Deadlock

Published by: Zaya

Published date: 22 Jun 2021

Causes (Conditions) of Deadlock Photo

Causes (Conditions) of Deadlock

A deadlock situation can arise if and only if the following four conditions hold simultaneously in a system-

  • Mutual Exclusion: At least one resource is held in a non-shareable mode that is only one process at a time can use the resource. If another process requests that resource, the requesting process must be delayed until the resource has been released. In the diagram below, there is a single instance of Resource 1 and it is held by Process 1 only

mutual exclusion

  • Hold and Wait: There must exist a process that is holding at least one resource and is waiting to acquire additional resources that are currently being held by other processes. In the diagram given below, Process 2 holds Resource 2 and Resource 3 and is requesting Resource 1 which is held by Process 1.
    hold and wait
  • No Preemption: Resources cannot be preempted; that is, a resource can only be released voluntarily by the process holding it after the process has completed its task. In the diagram below, Process 2 cannot preempt Resource 1 from Process 1. It will only be released when Process 1 relinquishes it voluntarily after its execution is complete.
    no preemption
  • Circular Wait: There must exist a set {p0, p1, pn} of waiting for processes such thatp0 is waiting for a resource which is held by p1, p1 is waiting for a resource which is held by p2,..., pn-1 is waiting for a resource which is held by pn and pn is waiting for a resource which is held by p0.

circular wait

NOTE: All four of these conditions must be present for a deadlock to occur. If one of them is absent, no deadlock is possible.

Handling Deadlock

• Deadlock detection
• Recovery from deadlock
• Deadlock prevention
• Deadlock avoidance
• Deadlock ignorance