deadlock - TarisMajor/5143-OpSystems GitHub Wiki

1699967450031

Deadlock

Deadlock is a situation in operating systems where a set of processes are blocked because each process is holding a resource and waiting for another resource held by another process, resulting in a cycle of dependencies that cannot be resolved.

Deadlock detection is the process of identifying when deadlock has occurred in a system. This involves analyzing system resources and processes to find a circular wait or other conditions that indicate a deadlock situation. Once detected, corrective actions can be taken to resolve the issue.

Deadlock prevention involves designing a system in such a way that the conditions necessary for deadlock are avoided. This can be achieved by ensuring that at least one of the four Coffman conditions (mutual exclusion, hold and wait, no preemption, circular wait) is not met, thus preventing the possibility of deadlock.

Deadlock avoidance is a strategy in which a system makes resource allocation decisions dynamically to ensure that the system will never enter a deadlock state. This typically involves analyzing resource requests ahead of time and using algorithms to grant or deny resources based on the potential for deadlock.

The Banker’s Algorithm is a resource allocation and deadlock avoidance algorithm that tests whether resource allocation can proceed without leading to a deadlock. It simulates the allocation of resources to processes and checks whether the system can eventually reach a safe state where all processes can finish without deadlock.

A Resource Allocation Graph (RAG) is a directed graph used to represent the relationships between processes and resources in a system. In a RAG, processes are represented by nodes, and resources are represented by nodes that are connected to processes by edges indicating resource allocation or requests. A cycle in the graph may indicate a deadlock.

Circular wait is one of the necessary conditions for deadlock. It occurs when a set of processes are waiting for resources in a circular chain, where each process is holding at least one resource and waiting for a resource held by another process in the chain.

Hold and wait is another condition that can lead to deadlock. It occurs when a process holds at least one resource and is waiting for additional resources that are currently being held by other processes. This can lead to a situation where processes are indefinitely waiting for resources, creating the potential for deadlock.

Sources:

  • Operating System Concepts by Abraham Silberschatz, Peter B. Galvin, and Greg Gagne
  • Modern Operating Systems by Andrew S. Tanenbaum and Herbert Bos
  • Introduction to Operating Systems by H.M. Deitel, Paul J. Deitel, and David R. Choffnes
  • Operating Systems: Design and Implementation by Andrew S. Tanenbaum
  • ChatGPT
⚠️ **GitHub.com Fallback** ⚠️