CS 551: Distributed Operating Systems
Silberschatz-Galvin Detection Algorithm

Silberschatz-Galvin Detection Algorithm

Silberschatz & Galvin (1994) provides the following WFG-based deadlock detection algorithm.
This is a truly distributed deadlock algorithm.

Each site maintains its own local WFG.
    This may include some non-local processes that are

For example, the local site 1 WFG above shows
The local site 2 WFG above shows
These do not show which processes are external to sites 1 or 2..

The algorithm expands the local WFGs by adding a node, Pex, to represent the external dependencies.

In Site 1 of the figure above,

In Site 2 of the figure above,

At this point, site 1 recognizes that it has a cycle in its expanded local WFG that contains Pex.
So it sends a deadlock message to site 2, because one of the known external dependencies of site 1 (P3) is on site 2.
This deadlock message contains not the entire WFG for site 1, but just the path for that part of the cycle that does not include Pex.

From this, site 2 updates its expanded local WFG as below:

Since site 2 now finds a cycle in its updated expanded WFG as well, and the process Pex is not in this cycle, deadlock is detected.

If, on the other hand, site 2 can only find a cycle that contains Pex, it would send a deadlock message to whatever other sites were known in its WFG.
It is possible that processes on several sites are involved in a deadlock cycle.

Problem: It is possible that two different sites may determine a cycle about the same time, and both will send a deadlock message to the other (initiating the check for deadlock).
So both sites will update their WFGs, perhaps finding more cycles or more processes involved in the cycles than are really involved in the true global state of the system.