220 likes | 339 Views
Prof Philippas Tsigas Distributed Computing and Systems Research Group. Distributed systems II A polynomial local solution to Mutual Exclusion. Doorways. Doorway is a separation mechanism of two areas.
E N D
Prof Philippas Tsigas Distributed Computing and Systems Research Group Distributedsystems IIA polynomial local solution to Mutual Exclusion
Doorways • Doorway is a separation mechanism of two areas. • Processes which pass a doorway at time T prevent neighbor processes entering the same area at a greater time than T until exiting the doorway.
Asynchronous Doorway EnryCode ExitCode m1 is the “I am going in” message
Synchronous Doorway • A process which desires to enter a synchronous doorway is required to wait for a situation in which all its neighbors are outside the doorway. This is implemented by checking for a process the states of its neighbors before it enters the doorway.
Synchronous Doorway Entrycode: Exitcode:
Based on slides from Jennifer Welch Link Reversal Algorithms
What is Link Reversal? • Distributed algorithm design technique • Used in solutions for a variety of problems • routing, leader election, mutual exclusion, scheduling, resource allocation,… • Model problem as a directed graph and reverse the direction of links appropriately • Use local knowledge to decide which links to reverse
Routing [Gafni & Bertsekas 1981] • Undirected connected graph represents communication topology of a system • Unique destination node • Assign virtual directions to the graph edges (links) s.t. • if nodes forward messages over the links, they reach the destination • Directed version of the graph (orientation) must • be acyclic • have destination as only sink Thus every node has path to destination.
Routing Example D 3 1 2 4 5 6
Mending Routes • What happens if some edges go away? • Might need to change the virtual directions on some remaining edges (reverse some links) • More generally, starting with an arbitrary directed graph, each node should decide independently which of its incident links to reverse
Mending Routes Example D 3 1 2 4 5 6
Sinks • A vertex with no outgoing links is a sink. • The property of being a sink can be detected locally. • A sink can then reverse some incident links • Basis of several algorithms… sink
Full Reversal Routing Algorithm • Input: directed graph G with destination vertex D • Let S(G) be set of sinks in G other than D • while S(G) is nonempty do • reverse every link incident on a vertex in S(G) • G now refers to resulting directed graph
D D D 3 1 2 2 1 3 3 2 1 4 5 4 6 5 6 5 4 6 D D D 3 2 1 3 2 1 1 2 3 4 5 6 4 5 6 4 5 6 Full Reversal (FR) Routing Example
Why Does FR Terminate? • Suppose it does not. • Let W be vertices that take infinitely many steps. • Let X be vertices that take finitely many steps; includes D. • Consider neighboring nodes w in W, x in X. • Consider first step by w after last step by x: link is w g x and stays that way forever. • Then w cannot take any more steps, contradiction.
Why is FR Correct? • Assume input graph is acyclic. • Acyclicity is preserved at each iteration: • Any new cycle introduced must include a vertex that just took a step, but such a vertex is now a source (has no incoming links) • When FR terminates, no vertex, except possibly D, is a sink. • A DAG must have at least one sink: • if no sink, then a cycle can be constructed • Thus output graph is acyclic and D is the unique sink.
References Resource Allocation and Link Reversal • Dijkstra, E. W. (1971, June). Hierarchical ordering of sequential processes. ActaInformatica 1(2): 115-138. • Chandy, K.M.; Misra, J. (1984). The Drinking Philosophers Problem. ACM Transactions on Programming Languages and Systems. • Nancy A. Lynch. Upper bounds for static resource allocation in a distributed system Journal for Computer and System Sciences, 23:254-278, 1981 • Manhoi Choy and Ambuj K. Singh. Efficient fault-tolerant algorithms for distributed resource allocation. ACM Transactions on Programming Languages and Systems, 17(3):535-559, May 1995. • Gafni and Bertsekas, “Distributed Algorithms for Generating Loop-Free Routes in Networks with Frequently Changing Topology,” IEEE Trans. Comm. 1981. • Welch and Walter, “Link Reversal Algorithms,” Synthesis Lectures on Distributed Computing Theory #8, Morgan & Claypool Publishers, 2012.