CS 551: Distributed Operating Systems
Chandy-Misra-Hass Detection Algorithm

Chandy-Misra-Hass Detection Algorithm

Another fully distributed deadlock detection algorithm is given by Chandy, Misra, and Hass (1983).
This is considered an edge-chasing, probe-based algorithm.
It is also considered one of the best deadlock detection algorithms for distributed systems.

If a process makes a request for a resource which fails or times out,
    the process generates a probe message and sends it to each of the processes holding one or more of its requested resources.

Each probe message contains the following information:

When a process receives a probe message,
    it checks to see if it is also waiting for resources.
If not, it is currently using the needed resource
    and will eventually finish and release the resource.
If it is waiting for resources, it passes on the probe message to all processes it knows to be holding resources it has itself requested.
The process first modifies the probe message, changing the sender and receiver ids.

If a process receives a probe message that it recognizes as having initiated,
    it knows there is a cycle in the system
    and thus, deadlock.

The following example is based on the same data used in the Silberschatz-Galvin algorithm example.
In this case P1 initiates the probe message, so that all the messages shown have P1 as the initiator.
When the probe message is received by process P3, it modifies it and sends it to two more processes.
Eventually, the probe message returns to process P1. Deadlock!

The advantages of this algorithm include the following: