A deadlock is a condition where each of the processes is waiting for a resource which is allotted to other processes. In this case, the process gets computed after the resource it requires is controlled by other processes, which is also looking for some other resource to be issued.
For example, suppose two freight trains are arriving toward each other on a single track, and there is the only same track, no trains can travel once they are in front of each other. The same condition takes place in the operating system if there are two processes that keep some resources and wait for resources controlled by other processes.

What is Deadlock in OS?
A deadlock in an operating system is a situation where a set of processes are blocked because each process is holding a resource and waiting for another resource acquired by some other process. This results in a cycle of dependencies that prevents any of the processes from proceeding. Deadlocks are critical issues that can halt the progress of a system, requiring careful management and prevention strategies.
There are some conditions for deadlock
- Mutual exclusion: There must be a minimum of one resource that can be utilized by only one process at the same moment in the system. When there is no such resource exist, then the process never suffer from the deadlock situation.
- Hold and wait: There should be a process that holds resources and waiting for other resources occupied by other operations.
- No preemption: A process that, once planned, will be computed till the termination. No other process can be scheduled at the same time by the scheduler.
- Circular wait: Entire process must be waiting for resources in a cyclic way. So, the last process is waiting for the resource that is being occupied by the initial process.
Methods for handling deadlock
- Deadlock prevention or avoidance: Prevention is done by invalidating the necessary conditions of the deadlock. Avoidance is advanced in nature. We have to ensure that entire information about resources will require are well-known to us. To avoid deadlock, we use Banker’s algorithm.
- Deadlock detection and recovery: We do preemption to manage deadlock when it happens.
- Ignore the problem altogether: When deadlock takes place, then allow it to occur and restart the system. This procedure is used by Windows and UNIX.
Similar Reads
-
Advantages and Disadvantage of User level and Kernel Level Threads
User-Level Threads Advantages of User-Level Threads Speed and Efficiency: Operations such as thread creation, switching, and destruction are faster because… -
Difference Between User-level and kernel-level thread
User-level and kernel-level threads represent two approaches to thread management in operating systems. Both have some differences Difference Between User-level… -
Preemptive and Non-Preemptive Algorithm in Operating System
Preemptive Scheduling Algorithm Here, a scheduler can preempt a running low-priority process at any time when a high-priority process enters… -
CPU scheduling algorithms Criteria in Operating System
There are different criteria for the CPU scheduling algorithm. CPU scheduling algorithms Criteria are CPU utilization: The main purpose of… -
Sleeping Barber Problem of Synchronization in Operating System
It is a synchronization and inter-process communication problem. This problem is based on a barbershop. A barbershop has a single… -
Reader-Writer Problem in Operating System with Code
The readers and writers problem based on an object like a file which is shared in different processes. Some processes… -
Discuss the Classical problem of synchronization
Using semaphores for synchronization is the traditional way to present the solutions. There are four types of the classical problem… -
Semaphore in Operating System and its types
A semaphore is simply an integer variable that is shared between multiple threads. We can also say A semaphore is… -
Mutual exclusion in Operating System with its four conditions
When a process is executed in a critical section, then no other process can be executed in their critical section.… -
Critical Section Problem in Operating System
A contention situation arises if two independent programs or processes want to access common data, and this can lead to…