Why Deadlocks Freeze System Progress
📖 Scenario: Imagine a busy office where several employees need to use shared printers and scanners. Sometimes, two employees each hold one device and wait for the other device to become free, causing all work to stop.
🎯 Goal: Build a simple explanation model that shows how deadlocks occur and why they freeze system progress.
📋 What You'll Learn
Create a dictionary called
resources with two keys: 'Printer' and 'Scanner', each with a value of 1 representing one device available.Create a dictionary called
employees with two keys: 'Alice' and 'Bob', each with a list of resources they currently hold.Create a variable called
waiting that shows which resource each employee is waiting for.Write a simple check to detect if both employees are waiting for a resource held by the other, indicating a deadlock.
💡 Why This Matters
🌍 Real World
Deadlocks can happen in computers when programs wait forever for resources, causing the system to freeze or slow down.
💼 Career
Understanding deadlocks is important for software developers and system administrators to design systems that avoid freezing and improve reliability.
Progress0 / 4 steps