
Concept Notes: Deadlocks
🔹 What is a Deadlock?
A Deadlock is a situation in an Operating System when two or more processes are waiting for resources, and none of them can proceed because the resources are held by each other in a circular chain.
👉 Simply: “Processes are stuck forever waiting.”
🔹 Deadlock Conditions (Coffman’s Conditions)
A deadlock can occur if all 4 conditions hold simultaneously:
- Mutual Exclusion
- Only one process can use a resource at a time.
- Hold and Wait
- A process is holding one resource and waiting for another.
- No Preemption
- Resources cannot be forcibly taken away; they must be released voluntarily.
- Circular Wait
- A circular chain of processes exists, where each process holds one resource and waits for the next.
🔹 Examples of Deadlock
Example 1 (Real-life):
- Two people trying to cross a narrow bridge at the same time → both are stuck, nobody can move.
Example 2 (OS):
- P1 holds Resource A, waiting for Resource B.
- P2 holds Resource B, waiting for Resource A.
→ Both are stuck → Deadlock.
⚙️ Important Conceptual Formulas / Points
Deadlock conditions are theoretical (no math formulas), but important OS definitions:
- Deadlock Occurrence:
Deadlock ⇔ Mutual Exclusion + Hold & Wait + No Preemption + Circular Wait
- Resource Allocation Graph (RAG):
- If the RAG contains a cycle → Deadlock may exist.
- If multiple instances exist → cycle ≠ always deadlock.
🔟 MCQs
Q1. Deadlock occurs when:
A) Only one condition of Coffman is true
B) All four conditions hold simultaneously
C) At least two conditions hold
D) None of the above
Q2. Which of the following is NOT a condition for deadlock?
A) Mutual Exclusion
B) Preemption
C) Hold and Wait
D) Circular Wait
Q3. Example of deadlock in real life is:
A) Printer and Keyboard both working
B) Two trains waiting for each other on a single track
C) Two processes using different CPUs
D) None
Q4. Resource Allocation Graph cycle always implies:
A) Deadlock definitely
B) Deadlock may exist
C) No Deadlock
D) Deadlock resolved
Q5. Which of these deadlock conditions can be removed by allowing preemption?
A) Circular Wait
B) Hold and Wait
C) No Preemption
D) Mutual Exclusion
Q6. Banker’s Algorithm is used for:
A) Deadlock Avoidance
B) Deadlock Detection
C) Deadlock Recovery
D) None
Q7. Deadlock prevention can be achieved by:
A) Eliminating Circular Wait
B) Allowing Hold and Wait
C) Enabling No Preemption
D) All of the above
Q8. Which is an example of Deadlock in OS?
A) Process waiting for I/O forever
B) Two processes holding resources and waiting for each other
C) Memory leak
D) CPU scheduling starvation
Q9. Deadlock detection requires:
A) Resource Allocation Graph
B) Gantt Chart
C) Paging Table
D) Segment Table
Q10. Deadlock recovery can be done by:
A) Process Termination
B) Resource Preemption
C) Both A & B
D) None
✅ Answer Key
Q.No | Answer |
---|---|
Q1 | B |
Q2 | B |
Q3 | B |
Q4 | B |
Q5 | C |
Q6 | A |
Q7 | A |
Q8 | B |
Q9 | A |
Q10 | C |
🧠 Explanations
- Q1: Deadlock requires all 4 Coffman conditions simultaneously → Ans: B
- Q2: “Preemption” is the opposite of “No Preemption” → Not a condition → Ans: B
- Q3: Two trains waiting → Deadlock example → Ans: B
- Q4: In single instance case → Cycle = Deadlock. In multiple instance → Cycle may exist → Ans: B
- Q5: Allowing resource preemption eliminates “No Preemption” → Ans: C
- Q6: Banker’s Algorithm is a deadlock avoidance method → Ans: A
- Q7: Deadlock prevention → eliminate any one condition, commonly Circular Wait → Ans: A
- Q8: Mutual waiting processes → Classic deadlock → Ans: B
- Q9: RAG is used to detect cycles (deadlock detection) → Ans: A
- Q10: Recovery = terminate processes or preempt resources → Ans: C
🎯 Motivation: Why Practice Deadlocks?
Deadlocks are a common interview and exam question in Operating Systems.
Understanding them helps in:
- Problem-solving mindset.
- Writing better resource management code.
- Performing well in ECET and engineering interviews.
👉 Remember: “If you can break even one condition, you can prevent a deadlock.”
📲 Call To Action
👉 Want more MCQs + Notes? Join our WhatsApp group for daily practice & explanations.