Deadlock Detection
Deadlock Detection
Given a wait-for graph, detect if a deadlock exists.
Function
func DetectDeadlock(n int, edges [][2]int) bool
Behavior
- There are
nprocesses labeled0..n-1. - Each edge
(u, v)means processuis waiting forv. - Return
trueiff 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