Dealing with Deadlock
1. Ignore it. “How big can those black boxes be anyway?”
2. Detect it and recover. Traverse the resource graph looking for cycles before blocking any customer.
- If a cycle is found, preempt: force one party to release and restart.
3. Prevent it statically by breaking one of the preconditions.
- Assign a fixed partial ordering to resources; acquire in order.
- Use locks to reduce multiple resources to a single resource.
- Acquire resources in advance of need; release all to retry.
4. Avoid it dynamically by denying some resource requests.