A resource-allocation graph has a node for each thread and each resource, an edge when thread waits for resource , and an edge when is held by . Lock ordering fixes a total order on the locks and requires every thread to acquire the locks it holds together in increasing order.
rag_cycle.py finds the cycle by depth-first search; with P3’s request withdrawn, it finds none.