Deadlock: conditions, prevention and avoidance
50 min · Intermediate
A deadlock is a set of processes where each one is waiting for a resource held by another one in the set, so none of them can ever continue. Picture two cars meeting on a narrow one-lane bridge from opposite ends: each waits for the other to reverse, and nobody moves.
Topics in this lesson
- The four Coffman conditions with a real-life example
- Resource allocation graphs
- Prevention vs avoidance vs detection and recovery
- Banker's algorithm worked example (safe sequence)
- Deadlock vs starvation
Interview questions this lesson answers
- What is a deadlock?
- Give a real-life example of deadlock.
- What are the four necessary conditions for deadlock?
- Explain hold and wait.
- Explain circular wait.
- What are the ways of handling deadlock?
- How can you prevent deadlock?
- Why can mutual exclusion usually not be removed?
- Which prevention technique is most used in real code?
- What is the downside of requesting all resources at the start?
Sign in free to continue this lesson
Create a free account to read every lesson, practise with the exercises and keep track of your progress.