Deadlock Detection

easy · os, deadlock, graph

Deadlock Detection

Given a wait-for graph, detect if a deadlock exists.

Function

func DetectDeadlock(n int, edges [][2]int) bool

Behavior

  • There are n processes labeled 0..n-1.
  • Each edge (u, v) means process u is waiting for v.
  • Return true iff the wait-for graph contains a cycle.

Notes

  • Use any cycle detection algorithm (DFS with colors is sufficient).
Run tests to see results
No issues detected