**Chapter 11**

**Detecting Termination and Deadlocks**

**11.1 Introduction**

Termination and deadlocks are crucial predicates in a distributed system. Generally, computations are expected to terminate and be free from deadlocks. It is an important problem in distributed computing to develop efficient algorithms for termination and deadlock detection. Note that both termination and deadlock are stable properties and therefore can be detected using any global snapshot algorithm. However, these predicates can be detected even more efficiently than general stable predicates. The reason for this efficiency is that these predicates are not only stable but also *locally* stable—the state of each process involved in the predicate does not change when the predicate becomes true. We will later define and exploit the locally stable property of the predicates to design efficient distributed algorithms.

To motivate termination detection, we consider a class of distributed computations called *diffusing* computations. We give a diffusing computation for the problem of determining the shortest path from a fixed process. The diffusing computation algorithm works except that one does not know when the computation has terminated.

**11.2 Diffusing Computation**

Consider a computation on a distributed system that is started by a special process called *environment*. This process starts up the computation by sending messages to some of the processes. Each process in the system is either *passive* or *active*. It is assumed ...