Deadlocks Illustrated

Explore how several processes request, hold, and release resources at your own pace. Step through animated graphs, compare safe and unsafe schedules.

Core ideas

The four Coffman conditions

Keep these cards nearby and check off each condition when you see it happen during the animation.

Mutual exclusion

Some resources (printers, mutexes, GPUs) allow only one owner at a time. If everything were shareable, deadlock couldn’t occur.

Hold and wait

Processes keep current allocations while asking for more. Try predicting when a process should release to avoid trouble.

No preemption

Locks, semaphores, or hardware devices usually can’t be stolen. A process must cooperate and release them willingly.

Circular wait

When requests form a cycle in the wait-for graph, progress stops. Break any edge in that cycle to recover.

Hands-on playground

Animate a deadlock, then fix it

Three processes (P1–P3) fight over three single-instance resources (R1–R3). Step slowly, narrate what changed, then switch to a safe ordering to see how a different policy keeps the system healthy.

Step 1 / 1

Pick a scenario to begin.

P1 P2 P3 R1 R2 R3

granted resource

pending request

deadlock alert

Apply the lesson

Prevention, avoidance, detection

Prevention

Impose a total ordering on resource requests or force processes to release everything before requesting new items.

Avoidance

Banker’s algorithm simulates the grant to ensure the system remains in a safe state. If not, delay the request yourself.

Detection & recovery

Periodically inspect the wait-for graph for cycles. Once you find one, preempt, roll back, or terminate a process.