一个 deadlock(死锁)是这样一种状态:两个或更多线程各自永远阻塞,每个都在等待另一个持有的资源。没有任何进展。
四个必要条件(Coffman 条件)
四个必须同时成立——去掉其中任何一个,deadlock 就不可能发生:
text
1. Mutual exclusion → a resource is held exclusively (only one holder at a time)
2. Hold and wait → a thread holds one resource while waiting to acquire another
3. No preemption → resources can't be forcibly taken; only released voluntarily
4. Circular wait → a cycle: T1 waits for R2 (held by T2), T2 waits for R1 (held by T1)
text
