distributed systems ii a polynomial local solution to mutual exclusion prof philippas tsigas...

22
DISTRIBUTED SYSTEMS II A POLYNOMIAL LOCAL SOLUTION TO MUTUAL EXCLUSION Prof Philippas Tsigas Distributed Computing and Systems Research Group

Upload: giles-robertson

Post on 05-Jan-2016

212 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: DISTRIBUTED SYSTEMS II A POLYNOMIAL LOCAL SOLUTION TO MUTUAL EXCLUSION Prof Philippas Tsigas Distributed Computing and Systems Research Group

DISTRIBUTED SYSTEMS II A POLYNOMIAL LOCAL SOLUTION TO MUTUAL EXCLUSION

Prof Philippas TsigasDistributed Computing and Systems Research Group

Page 2: DISTRIBUTED SYSTEMS II A POLYNOMIAL LOCAL SOLUTION TO MUTUAL EXCLUSION Prof Philippas Tsigas Distributed Computing and Systems Research Group

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.

Page 3: DISTRIBUTED SYSTEMS II A POLYNOMIAL LOCAL SOLUTION TO MUTUAL EXCLUSION Prof Philippas Tsigas Distributed Computing and Systems Research Group

Asynchronous Doorway

Enry Code Exit Code

m1 is the “I am going in” message

Page 4: DISTRIBUTED SYSTEMS II A POLYNOMIAL LOCAL SOLUTION TO MUTUAL EXCLUSION Prof Philippas Tsigas Distributed Computing and Systems Research Group

Behavior

Page 5: DISTRIBUTED SYSTEMS II A POLYNOMIAL LOCAL SOLUTION TO MUTUAL EXCLUSION Prof Philippas Tsigas Distributed Computing and Systems Research Group

Problem with the Asynchronous Doorway

Page 6: DISTRIBUTED SYSTEMS II A POLYNOMIAL LOCAL SOLUTION TO MUTUAL EXCLUSION Prof Philippas Tsigas Distributed Computing and Systems Research Group

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.

Page 7: DISTRIBUTED SYSTEMS II A POLYNOMIAL LOCAL SOLUTION TO MUTUAL EXCLUSION Prof Philippas Tsigas Distributed Computing and Systems Research Group

Synchronous Doorway

Entry code: Exit code:

Page 8: DISTRIBUTED SYSTEMS II A POLYNOMIAL LOCAL SOLUTION TO MUTUAL EXCLUSION Prof Philippas Tsigas Distributed Computing and Systems Research Group

What Can Go Wrong?

Page 9: DISTRIBUTED SYSTEMS II A POLYNOMIAL LOCAL SOLUTION TO MUTUAL EXCLUSION Prof Philippas Tsigas Distributed Computing and Systems Research Group

What if We Combine?

Page 10: DISTRIBUTED SYSTEMS II A POLYNOMIAL LOCAL SOLUTION TO MUTUAL EXCLUSION Prof Philippas Tsigas Distributed Computing and Systems Research Group
Page 11: DISTRIBUTED SYSTEMS II A POLYNOMIAL LOCAL SOLUTION TO MUTUAL EXCLUSION Prof Philippas Tsigas Distributed Computing and Systems Research Group

LINK REVERSAL ALGORITHMS

Based on slides from Jennifer Welch

Page 12: DISTRIBUTED SYSTEMS II A POLYNOMIAL LOCAL SOLUTION TO MUTUAL EXCLUSION Prof Philippas Tsigas Distributed Computing and Systems Research Group

12

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

Page 13: DISTRIBUTED SYSTEMS II A POLYNOMIAL LOCAL SOLUTION TO MUTUAL EXCLUSION Prof Philippas Tsigas Distributed Computing and Systems Research Group

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. 13

Page 14: DISTRIBUTED SYSTEMS II A POLYNOMIAL LOCAL SOLUTION TO MUTUAL EXCLUSION Prof Philippas Tsigas Distributed Computing and Systems Research Group

Routing Example

14

D

1 2 3

4 5 6

Page 15: DISTRIBUTED SYSTEMS II A POLYNOMIAL LOCAL SOLUTION TO MUTUAL EXCLUSION Prof Philippas Tsigas Distributed Computing and Systems Research Group

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

15

Page 16: DISTRIBUTED SYSTEMS II A POLYNOMIAL LOCAL SOLUTION TO MUTUAL EXCLUSION Prof Philippas Tsigas Distributed Computing and Systems Research Group

Mending Routes Example

16

D

1 2 3

4 5 6

Page 17: DISTRIBUTED SYSTEMS II A POLYNOMIAL LOCAL SOLUTION TO MUTUAL EXCLUSION Prof Philippas Tsigas Distributed Computing and Systems Research Group

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…

17

Page 18: DISTRIBUTED SYSTEMS II A POLYNOMIAL LOCAL SOLUTION TO MUTUAL EXCLUSION Prof Philippas Tsigas Distributed Computing and Systems Research Group

Full Reversal Routing Algorithm

18

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

Page 19: DISTRIBUTED SYSTEMS II A POLYNOMIAL LOCAL SOLUTION TO MUTUAL EXCLUSION Prof Philippas Tsigas Distributed Computing and Systems Research Group

19

Full Reversal (FR) Routing Example

D

1 2 3

4 5 6

D

1 2 3

4 5 6

D

1 2 3

4 5 6

D

1 2 3

4 5 6

D

1 2 3

4 5 6

D

1 2 3

4 5 6

Page 20: DISTRIBUTED SYSTEMS II A POLYNOMIAL LOCAL SOLUTION TO MUTUAL EXCLUSION Prof Philippas Tsigas Distributed Computing and Systems Research Group

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.

20

Page 21: DISTRIBUTED SYSTEMS II A POLYNOMIAL LOCAL SOLUTION TO MUTUAL EXCLUSION Prof Philippas Tsigas Distributed Computing and Systems Research Group

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.

21

Page 22: DISTRIBUTED SYSTEMS II A POLYNOMIAL LOCAL SOLUTION TO MUTUAL EXCLUSION Prof Philippas Tsigas Distributed Computing and Systems Research Group

References Resource Allocation and Link Reversal

Dijkstra, E. W. (1971, June). Hierarchical ordering of sequential processes. Acta Informatica 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.

22