Level 1: Bronze
A memorized definition. Not wrong, but it stops there.
Processes wait on each other's resources and all of them stop.
3 stars If you are short on time, start with this one.
In one or two sentences
Several tasks wait forever for resources held by each other. It happens when mutual exclusion, hold and wait, no preemption and circular wait all hold at once.
Say it out loud, or type it below. What you type never leaves this device.
A memorized definition. Not wrong, but it stops there.
Processes wait on each other's resources and all of them stop.
Correct, but too broad or missing context.
If mutual exclusion, hold and wait, no preemption and circular wait all hold, you get a deadlock. Break any one of them and it cannot happen.
Reaches principle, use and trade-off, with words that invite the next question.
All four must hold together, so breaking one is enough. Prevention breaks a condition by design: number the resources and always lock in the same order, and circular wait disappears. Avoidance, such as the banker's algorithm, checks that a safe state remains before granting a request, but it needs maximum demands in advance, so it is rare in practice. Detection and recovery lets deadlocks happen, finds the cycle, then kills a process or takes a resource. Textbooks note that general purpose OSes usually leave deadlocks to applications, and in practice teams rely on lock ordering rules and timeouts.
These are likely next questions from an interviewer. Think of your answer first, then press the button.
1 / 3
How is deadlock different from starvation?
In a deadlock every task involved is stuck. In starvation only some tasks keep missing out on a resource while the rest keep running.
2 / 3
How do you avoid deadlocks in code?
Pick one global order for taking locks and shorten the sections where you hold one lock and wait for another. Try-lock with a timeout, then release what you hold and retry, also works.
3 / 3
What does the banker's algorithm check?
Whether, after granting a request, there is still some order in which every process can finish. That is a safe state. If not, the request waits.
This is a textbook level concept, so no outside source is listed.