- Trending Categories
- Data Structure
- Operating System
- MS Excel
- C Programming
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
A deadlock happens in operating system when two or more processes need some resource to complete their execution that is held by the other process.
A deadlock occurs if the four Coffman conditions hold true. But these conditions are not mutually exclusive. They are given as follows −
There should be a resource that can only be held by one process at a time. In the diagram below, there is a single instance of Resource 1 and it is held by Process 1 only.
Hold and Wait
A process can hold multiple resources and still request more resources from other processes which are holding them. In the diagram given below, Process 2 holds Resource 2 and Resource 3 and is requesting the Resource 1 which is held by Process 1.
A resource cannot be preempted from a process by force. A process can only release a resource voluntarily. In the diagram below, Process 2 cannot preempt Resource 1 from Process 1. It will only be released when Process 1 relinquishes it voluntarily after its execution is complete.
A process is waiting for the resource held by the second process, which is waiting for the resource held by the third process and so on, till the last process is waiting for a resource held by the first process. This forms a circular chain. For example: Process 1 is allocated Resource2 and it is requesting Resource 1. Similarly, Process 2 is allocated Resource 1 and it is requesting Resource 2. This forms a circular wait loop.
- Related Articles
- Difference between Deadlock Prevention and Deadlock Avoidance
- Deadlock Avoidance
- Deadlock Prevention
- Starvation and Deadlock
- Deadlock System Model
- Deadlock, Starvation & LiveLock
- Deadlock in Java Multithreading
- Deadlock with mutex locks
- Deadlock Detection and Recovery
- Deadlock and Starvation in C#
- Deadlock ignorance in Operating system
- Display all deadlock logs in MySQL?
- Deadlock Detection Algorithm in Operating System
- Difference Between Deadlock and Starvation in OS
- Why analytical characterization and attribute relevance analysis are needed and how these can be performed?