Study Atlas › Computer Science › Systems

Concurrency: deadlock and synchronisation

Running tasks at once safely; deadlock occurs when tasks wait forever for each other's resources.

Edited by Alex C, EduAlx · Sources cited below

Explanation

Dijkstra introduced semaphores (1965) and the dining philosophers problem. Coffman's four conditions for deadlock are mutual exclusion, hold and wait, no pre-emption and circular wait. Locks, monitors (Hoare) and message passing prevent race conditions. Lamport's work on distributed systems received the 2013 Turing Award.

Example

Two bank transfers locking accounts A then B, and B then A, can deadlock; always locking in a fixed order prevents it.

How it works, step by step

  1. Identify shared data
  2. Protect it with a lock or semaphore
  3. Order lock acquisition to avoid cycles
  4. Test under load for races

Open the interactive page with diagrams →

People behind it

References

  1. E. W. Dijkstra, Commun. ACM 1965, 8, 569.
  2. E. G. Coffman, M. Elphick, A. Shoshani, ACM Comput. Surv. 1971, 3, 67–78.
  3. L. Lamport, Commun. ACM 1978, 21, 558–565.

Textbooks

Related topics

File systems and storageOperating systems: processes, scheduling and memoryVirtualisation and containersCloud computingRelational databases and SQLComputer networks and the TCP/IP modelVon Neumann architectureWorld Wide Web, HTTP and HTMLBoolean logic and digital circuitsInformation theory and entropy