Lably
Skip to content

Deadlock (computer science)

State in which members are blocking each other

  • 7 min read
  • 4 chapters

Related on Lably

Through Distributed computing, Operating system and Process (computing)

In an operating system, a deadlock occurs when a process or thread enters a waiting state because a requested system resource is held by another waiting process, which in turn is waiting for another resource held by another waiting process. If a process remains indefinitely unable to change its state because resources requested by it are being used by another process that itself is waiting, then the system is said to be in a deadlock.

In a communications system, deadlocks occur mainly due to loss or corruption of signals rather than contention for resources.

Conditions

A deadlock situation on a resource can arise only if all of the following conditions occur simultaneously in a system:

  1. Mutual exclusion: multiple resources are not shareable; only one process at a time may use each resource.
  2. Hold and wait or resource holding: a process is currently holding at least one resource and requesting additional resources which are being held by other processes.
  3. No preemption: a resource can be released only voluntarily by the process holding it.
  4. Circular wait: each process must be waiting for a resource which is being held by another process, which in turn is waiting for the first process to release the resource. In general, there is a set of waiting processes, P = {P1, P2, ..., PN}, such that P1 is waiting for a resource held by P2, P2 is waiting for a resource held by P3 and so on until PN is waiting for a resource held by P1.

These four conditions are known as the Coffman conditions from their first description in a 1971 article by Edward G. Coffman, Jr.

While these conditions are sufficient to produce a deadlock on single-instance resource systems, they only indicate the possibility of deadlock on systems having multiple instances of resources.

Sign in to keep reading

3 more chapters are free with a Lably account.

More in Computing and communication