Operating Systems

Unit 5: Deadlock

From deadlock characterization to Banker's Algorithm — master numerical problems, resource allocation graphs, and prevention strategies used in real operating systems.

⏱️ Time to Complete: 7 hrs theory + 5 hrs lab  |  💰 Earning Potential: ₹8K–₹25K/month  |  📝 30 MCQs (Bloom's Mapped)

💼 Jobs this unlocks: Systems Engineer (₹6–10 LPA)  |  Site Reliability Engineer (₹8–18 LPA)

Section A

Opening Hook — The Deadlock You Can See

🚗 Mumbai's Chandni Chowk Lane — Two Autos, Zero Movement

Picture this: a narrow lane in Mumbai's Chandni Chowk area. Two auto-rickshaws enter from opposite ends — nose-to-nose. Neither can reverse because behind each auto, 50 more autos have queued up. The lane is barely wide enough for one vehicle. Auto A holds position in the left half and needs the right half to pass. Auto B holds position in the right half and needs the left half to pass. Both hold what the other needs. Neither will back down.

The entire lane is DEADLOCKED. Traffic police arrive, but even they can't solve it without forcibly towing one auto (preemption) or making all autos in one direction reverse (rollback). Now imagine this happening inside your operating system — but instead of autos, there are 4 processes, and instead of lane space, they hold printers, memory blocks, and disk drives.

"Could YOU have prevented this?" — That's exactly what this unit teaches. You'll learn to detect, prevent, avoid, and recover from deadlocks. And you'll solve Banker's Algorithm numericals that appear in every OS exam.

🇮🇳 Flipkart🇮🇳 RBI Core Banking🇮🇳 IRCTC🇮🇳 Google India🇮🇳 Amazon India🇮🇳 Razorpay
In 2015, a real deadlock in the MySQL database at Flipkart during Big Billion Days caused thousands of orders to hang for 47 minutes. Two transaction threads each held a row lock and waited for the other's lock. The fix? Implementing a deadlock detection timeout of 5 seconds. This single bug cost an estimated ₹2.3 crore in lost sales. The engineer who fixed it? She used the exact Banker's Algorithm logic you'll learn in this chapter.
Section B

Learning Outcomes — Bloom's Taxonomy Mapped

Bloom's LevelLearning Outcome
🔵 RememberList the 4 necessary conditions for deadlock and define safe/unsafe states
🔵 UnderstandExplain why circular wait + hold & wait cause deadlock using RAG diagrams
🟢 ApplyExecute Banker's Algorithm step-by-step: compute Need matrix, find safe sequence, evaluate resource requests
🟢 AnalyzeAnalyze Resource Allocation Graphs to detect cycles and determine if deadlock exists
🟠 EvaluateCompare prevention vs avoidance vs detection strategies and recommend the best approach for given scenarios
🟠 CreateImplement a complete Banker's Algorithm simulator in Python and build a RAG visualizer