Termination Detection of Diffusing Computations Chapter 19 Distributed Algorithms by Nancy Lynch Presented by Jamie Payton Oct. 3, 2003
Motivation We would like to simplify programming of asynchronous networks Use a monitoring algorithm Debugging Backup Termination detection Deadlock detection Global quantity computation
Approaches Stable property detection Any property of the global state that, once established, remains true E.g., deadlock or termination Consistent global snapshots Captures the global state of the network such that it appears to all processes to have been taken at the same instant on every process
Asynchronous Networks Collection of processes Collection of channels Communication subsystem Point-to-point Broadcast Multicast
Network Model n-Node directed graph G=(V,E) Represent n processes as nodes in graph Represent channels as directed edges in graph
Send/Receive Model Processes Input actions Receive(m) i,j Output actions Send(m) i,j Channels Input actions Send(m) i,j Output actions Receive(m) i,j Each process associated with a node and each channel associated with an edge in the graph G is modeled as an I/O automaton
Termination Detection for Diffusing Computations All processes are initially quiescent A designated “live” process diffuses computation to other processes Processes awaken, perform work, spread computation Processes become quiescent again When all processes become quiescent, then termination should be signaled
Problem Statement (1) Initially No locally controlled actions can be performed All channels are empty A single process is awakened with an input event from the environment It can perform an output action to generate an event, send, for other processes A process performs an input action, receive, which wakes up the process Awakened processes perform tasks and spread computation with output actions A process becomes quiescent again when No locally controlled action can be performed; No messages exist in its channel
Problem Statement (2) Given the initial state of the network as described, If a process A i at node n i receives an input event, and after some time a global quiescent state is reached, then a special done i output should be performed at node i
Detecting Termination Detect termination of algorithm A with a monitoring algorithm, B(A) Send/receive algorithm Based on the graph G Issues a special done output when termination is detected
Dijkstra-Scholten Algorithm(1) Basic idea: Augment the diffusing algorithm with construction and maintenance of a spanning tree Tree is rooted at the source node of the diffusing computation Tree includes all active nodes Tree grows/shrinks as nodes become active/idle
Dijkstra-Scholten Algorithm(2) All nodes are initially idle A single node, the source of the diffusing computation, becomes active An idle node receives a message from the diffusing computation algorithm, A Becomes active Records the sender as its parent Does not ack the message until ready to become idle again An active node must wait for all outgoing messages to be acknowledged before becoming idle again
Example A1A1 A4A4 A3A3 A2A2
Dijkstra-Scholten Automaton (1) Signature of DS(A i ) Signature of A i Input Receive(“ack”) j,I where j nbrs Output Send(“ack”) i,j where j nbrs Internal Cleanup i Done i
Dijkstra-Scholten Automaton (2) State information for DS(A i ) All state info for diffusing computation A i s i {idle, root, non-root}, initially idle p i nbrs {null}, initially null j nbrs: send-buffer(j), a FIFO queue of ack msgs, initially empty deficit(j) N, initially 0
Dijkstra-Scholten Automaton (3) Transitions See handout
Lemma In any state after an input at node i, s i {root, idle} and p i = null j≠i, s j {idle, non-root}, and if s j =non-root, then p j = null j, if s j =idle then the projected state of A j is quiescent, p j =null, and deficit(k) j =0 for every k j,k, deficit(k) j = numMsgs j,k + numBufAcks j,k + numAcks j,k + {1 if p k = j, 0 otherwise} If s i = root, then the parent pointers form a directed tree rooted at i which spans the set of nodes with s ≠ idle If s i = idle, then s j = idle for all j and all channels are empty
Proof Outline (1) The Dijkstra-Scholten algorithm detects termination for a diffusing algorithm A Lemma implies that if root announces termination, then A is quiescent Must show liveness property If A becomes quiescent, then the root eventually announces termination
Proof Outline (2) Proof by contradiction: Assume that A becomes quiescent and no done event occurs After this point, no A messages are sent or received again The tree cannot grow The tree must eventually stop shrinking Eventually, there are no further ack messages in the global state
Proof Outline (3) j,k, deficit(k) j = {1 if p k = j, 0 otherwise } This means that the cleanup action is enabled The tree can shrink further -- Contradiction
Complexity Analysis Messages 2m, where m is the number of messages sent by the algorithm A Time O(m(l+d)) l is an upper bound on time associated with a process performing a task d is an upper bound on time associated with a channel to perform a task
Consistent Global Snapshots
CSG Problem Statement
Chandy-Lamport Algorithm
Example
Proof Outline
CSG Applications
Conclusions Use a monitoring algorithm to detect termination of a computation Use a spanning tree to track nodes participating in the computation Use acks and message counters to maintain tree