Chandy–Misra–Haas algorithm resource model
![]() | This article has multiple issues. Please help improve it or discuss these issues on the talk page. (Learn how and when to remove these messages)
|
K. Mani Chandy, Jayadev Misra and Laura M Haas devised the Chandy-Misra-Haas algorithm for Resource Model. It checks whether there is any deadlock in a distributed system or not.
Locally Dependent

Consider there are n process P1,P2,P3,P4,P5............,Pn which are being performed in a single system(controller). P1 is locally dependent on Pn, if P1 depends on P2,P2 on P3 so on till Pn-1 on Pn. P1 is said to be locally dependent to itself if it is locally dependent on Pn and Pn depends on P1.
Description
The Algorithm uses a message called probe(i,j,k) to transfer a message from controller of process Pj to controller of process Pk. It specifies message was started by process Pi to find whether a deadlock has occurred or not. Every process Pj maintains a boolean array dependentj which contains the information about the process which are depending on it. Initially the value of each array is "false".
Controller sending a probe
The algorithm works like this: before sending the probe the controller checks whether Pj is locally dependent to itself or not. If it is locally dependent to itself then a deadlock has occurred.If it is not dependent to itself then it checks whether Pj,Pk are in different controllers, locally dependent and Pj is waiting for the resource that is locked by Pk. Once all the conditions are satisfied it sends the probe.
Controller receiving a probe
In the receiving side, the controller checks whether Pk is performing any task or not. If it is not idle, then it neglects the probe. Otherwise, it checks the responses given Pk to Pj and dependentk(i) is false. Once it verifies then it assign true to dependentk(i). After going through all those steps, in the end it checks whether k is equal to i. If both are equal then a deadlock has been occurred or else it sends probe to next dependent process.
Algorithm[1]
Controller sending a probe
if Pj is locally dependent on itself then declare deadlock else for all Pj,Pk such that (i) Pi is locally dependent on Pj, (ii) Pj is waiting for 'Pk and (iii) Pj, Pk are on different controllers. send probe(i, j, k).
Controller receiving a probe
if (i)Pk is idle, (ii) dependentk(i) = false, and (iii)requests responded by Pk to Pj then begin "dependents""k"(i) = true; if k == i then declare that Pi is deadlocked else for all Pa,Pb such that (i) Pk is locally dependent on Pa, (ii) Pa is waiting for 'Pb and (iii) Pa, Pb are on different controllers. send probe(i, a, b). end
Example

In the shown example, P1 initiates the deadlock detection. C1sends the probe saying P2 depends on P3. Once the message is received by C2, it checks whether P3 is idle. P3 is idle because it is locally dependent on P4 and updates dependent3(2) to True.
Same as above, C2 sends probe to C3 and C3 sends probe to C1. At C1 P1 is idle so it update dependent1(1) to true. Therefore it can be declared a deadlock has occurred.
Complexity
Consider that there are "m" controllers and "p" process to perform, to declare whether a deadlock has occurred or not, it need to visit in worst case all controllers and process. Therefore, it takes O(m+p) to detect a deadlock. It can be said the time complexity is O(n).
References
- ^ Chandy, K. M.; Misra, J.; Haas, L. M. (1983). "Distributed deadlock detection". ACM Transactions on Computer Systems. 1 (2): 144. doi:10.1145/357360.357365.