This article was automatically translated from the original Turkish version.

Deadlock, in computer science—particularly in operating systems and concurrent programming—is a situation in which two or more processes or threads are unable to proceed because each is waiting for a resource held by another. This results in a system-wide halt, preventing any of the involved processes from completing. Deadlock typically arises from improper management of shared resources such as memory, files, or database locks, and represents a serious issue for performance and reliability in modern computing systems. Unlike evaluation tools such as the resource allocation graph, deadlock formation is directly tied to system design and resource management. This article examines in detail the causes, conditions, prevention methods, and resolution approaches of deadlock.
Deadlock occurs when multiple processes or threads attempt to access specific resources simultaneously and block each other during access. For example, if one process holds a resource and needs another that is held by a second process, while the second process is waiting for the first resource, neither can proceed. This creates a circular wait condition in the system, making completion of the processes impossible.
Four fundamental conditions must hold simultaneously for a deadlock to occur; these are known as the Coffman conditions:
When all four conditions occur together, deadlock becomes inevitable. It is essential to examine each of these conditions individually to understand and prevent deadlock.

Diagram illustrating a deadlock scenario between two processes (P1 and P2) holding two resources (R1 and R2) and waiting for each other’s resources. (Image generated by artificial intelligence.)
Deadlocks are commonly observed in systems involving multiple threads or processes. Below are common scenarios and examples that lead to deadlock.
In operating systems, processes often compete for access to resources such as files, memory, or input/output devices. For instance, if two processes (P1 and P2) use two resources (R1 and R2), and P1 locks R1 while waiting for R2, while P2 locks R2 while waiting for R1, a deadlock occurs. This situation is frequently encountered in database systems that employ locking mechanisms.
In database management systems, transactions can deadlock when they attempt to access multiple tables or rows simultaneously. For example, if one transaction updates a table while waiting to access another, and a second transaction follows the reverse order of locking, both transactions become blocked. Modern database systems use deadlock detection algorithms to identify and resolve such situations.
In concurrent programming, particularly in multithreaded applications, deadlocks can occur when lock mechanisms are misused. For instance, in Java, two threads can deadlock if each is waiting for a monitor held by the other. The following simple Java code example demonstrates deadlock formation:
In this code, two threads attempt to lock two resources in opposite orders, resulting in a deadlock.
Various strategies have been developed to prevent or resolve deadlocks. These strategies vary depending on system design and application context.
Deadlock prevention aims to eliminate deadlock entirely by ensuring that at least one of the Coffman conditions cannot occur:
Some systems prefer to detect and recover from deadlocks rather than prevent them. Deadlock detection is performed using methods such as resource allocation graphs or wait-for chain analysis. Once detected, the system typically recovers by terminating one process or releasing its resources. For example, in database systems, a transaction can be rolled back and restarted.
Deadlock avoidance dynamically evaluates resource allocation decisions. The Banker’s Algorithm is a well-known method used in operating systems for this purpose. This algorithm analyzes resource requests to ensure the system remains in a safe state.
Deadlock management can impact system performance and complexity. For instance, prevention methods may lead to inefficient resource usage or complicate system design. Detection and recovery methods introduce additional computational overhead and may cause data loss through process termination. Moreover, in real-time systems, rapid resolution of deadlocks is critical.

Foundations of Deadlock
Conditions for Deadlock
Causes and Examples of Deadlock
Deadlock in Operating Systems
Deadlock in Database Systems
Deadlock at the Programming Level
Deadlock Prevention and Resolution Methods
Deadlock Prevention
Deadlock Detection and Recovery
Deadlock Avoidance
Limitations and Considerations