Deadlock
Medium+14 XPWatch two processes each hold what the other needs — and freeze forever in a circular wait.
No visualization loaded.
Watch
—
Press Run to begin.
Deadlock is when processes get stuck waiting on each other forever, and nothing can move. Press Run to watch two processes each grab one resource, then each wait for the one the other is holding — a circular wait with no way out.
▸Why don't they just give up their resource?
Because each one is mid-task and needs to KEEP what it has to finish — it's only waiting for ONE more thing. Neither will let go first, so they wait on each other forever. It's like two people in a doorway each refusing to step back.
▸What's a 'circular wait'?
The loop you see at the end: P1 waits for P2, and P2 waits for P1. Follow the arrows and they form a circle. That circle is the signature of a deadlock — if you can trace a loop of 'waiting for', nobody in it can ever proceed.
▸What conditions make deadlock possible?
Four must ALL be true: resources can't be shared (mutual exclusion), processes hold one while waiting for another (hold-and-wait), nothing can be forcibly taken away (no preemption), and there's a circular wait. Break any one of the four and deadlock can't happen.
▸How do real systems deal with it?
A few ways: prevent it (e.g. make everyone grab resources in the same fixed order, so no cycle can form), detect it and kill one process to break the loop, or just avoid risky grabs. The simplest trick is consistent ordering — it kills the circular wait.