Presentation is loading. Please wait.

Presentation is loading. Please wait.

Tanenbaum & Van Steen, Distributed Systems: Principles and Paradigms, 2e, (c) 2007 Prentice-Hall, Inc. All rights reserved. 0-13-239227-5 DISTRIBUTED SYSTEMS.

Similar presentations


Presentation on theme: "Tanenbaum & Van Steen, Distributed Systems: Principles and Paradigms, 2e, (c) 2007 Prentice-Hall, Inc. All rights reserved. 0-13-239227-5 DISTRIBUTED SYSTEMS."— Presentation transcript:

1 Tanenbaum & Van Steen, Distributed Systems: Principles and Paradigms, 2e, (c) 2007 Prentice-Hall, Inc. All rights reserved. 0-13-239227-5 DISTRIBUTED SYSTEMS Principles and Paradigms Second Edition ANDREW S. TANENBAUM MAARTEN VAN STEEN Chapter 6/B Synchronization Modified by Dr. Gheith Abandah

2 Tanenbaum & Van Steen, Distributed Systems: Principles and Paradigms, 2e, (c) 2007 Prentice-Hall, Inc. All rights reserved. 0-13-239227-5 Overview Clock Synchronization Physical Clocks Global Positioning System Clock Synchronization Algorithms Logical Clocks Lamport’s Logical Clocks Vector Clocks Mutual Exclusion Overview Centralized Algorithm A Decentralized Algorithm A Distributed Algorithm A Token Ring Algorithm A Comparison of the Four Algorithms Global Positioning of Nodes Election Algorithms Traditional Election Algorithms Elections in Wireless Environments Elections in Large-scale Systems

3 Tanenbaum & Van Steen, Distributed Systems: Principles and Paradigms, 2e, (c) 2007 Prentice-Hall, Inc. All rights reserved. 0-13-239227-5 Mutual Exclusion Problem A number of processes in a distributed system want exclusive access to some resource. Basic solutions Via a centralized server. Completely decentralized, using a peer-to-peer system. Completely distributed, with no topology imposed. Completely distributed along a (logical) ring.

4 Tanenbaum & Van Steen, Distributed Systems: Principles and Paradigms, 2e, (c) 2007 Prentice-Hall, Inc. All rights reserved. 0-13-239227-5 A Centralized Algorithm (1) (a) Process 1 asks the coordinator for permission to access a hared resource. Permission is granted.

5 Tanenbaum & Van Steen, Distributed Systems: Principles and Paradigms, 2e, (c) 2007 Prentice-Hall, Inc. All rights reserved. 0-13-239227-5 A Centralized Algorithm (2) (b) Process 2 then asks permission to access the same resource. The coordinator does not reply.

6 Tanenbaum & Van Steen, Distributed Systems: Principles and Paradigms, 2e, (c) 2007 Prentice-Hall, Inc. All rights reserved. 0-13-239227-5 A Centralized Algorithm (3) (c) When process 1 releases the resource, it tells the coordinator, which then replies to 2.

7 Tanenbaum & Van Steen, Distributed Systems: Principles and Paradigms, 2e, (c) 2007 Prentice-Hall, Inc. All rights reserved. 0-13-239227-5 A Decentralized Algorithm Principle Assume every resource is replicated n times, with each replica having its own coordinator → access requires a majority vote from m > n/2 coordinators. A coordinator always responds immediately to a request. Assumption When a coordinator crashes, it will recover quickly, but will have forgotten about permissions it had granted.

8 Tanenbaum & Van Steen, Distributed Systems: Principles and Paradigms, 2e, (c) 2007 Prentice-Hall, Inc. All rights reserved. 0-13-239227-5 A Distributed Algorithm (1) On reception of a resource request: 1.If the receiver is not accessing the resource and does not want to access it, it sends back an OK message to the sender. 2.If the receiver already has access to the resource, it simply does not reply. Instead, it queues the request. 3.If the receiver wants to access the resource as well but has not yet done so, it compares the timestamp of the incoming message with the one contained in the message that it has sent everyone. The lowest one wins.

9 Tanenbaum & Van Steen, Distributed Systems: Principles and Paradigms, 2e, (c) 2007 Prentice-Hall, Inc. All rights reserved. 0-13-239227-5 A Distributed Algorithm (2) (a) Two processes want to access a shared resource at the same moment.

10 Tanenbaum & Van Steen, Distributed Systems: Principles and Paradigms, 2e, (c) 2007 Prentice-Hall, Inc. All rights reserved. 0-13-239227-5 A Distributed Algorithm (3) (b) Process 0 has the lowest timestamp, so it wins.

11 Tanenbaum & Van Steen, Distributed Systems: Principles and Paradigms, 2e, (c) 2007 Prentice-Hall, Inc. All rights reserved. 0-13-239227-5 A Distributed Algorithm (4) (c) When process 0 is done, it sends an OK also, so 2 can now go ahead. However, this algorithm is not efficient (it uses multicast) and is not robust.

12 Tanenbaum & Van Steen, Distributed Systems: Principles and Paradigms, 2e, (c) 2007 Prentice-Hall, Inc. All rights reserved. 0-13-239227-5 A Token Ring Algorithm (a) An unordered group of processes on a network. (b) A logical ring constructed in software. Organize processes in a logical ring, and let a token be passed between them. The one that holds the token is allowed to enter the critical region (if it wants to).

13 Tanenbaum & Van Steen, Distributed Systems: Principles and Paradigms, 2e, (c) 2007 Prentice-Hall, Inc. All rights reserved. 0-13-239227-5 A Comparison of the Four Algorithms A comparison of four mutual exclusion algorithms. m number of coordinators k number of attempts

14 Tanenbaum & Van Steen, Distributed Systems: Principles and Paradigms, 2e, (c) 2007 Prentice-Hall, Inc. All rights reserved. 0-13-239227-5 Overview Clock Synchronization Physical Clocks Global Positioning System Clock Synchronization Algorithms Logical Clocks Lamport’s Logical Clocks Vector Clocks Mutual Exclusion Overview Centralized Algorithm A Decentralized Algorithm A Distributed Algorithm A Token Ring Algorithm A Comparison of the Four Algorithms Global Positioning of Nodes Election Algorithms Traditional Election Algorithms Elections in Wireless Environments Elections in Large-scale Systems

15 Tanenbaum & Van Steen, Distributed Systems: Principles and Paradigms, 2e, (c) 2007 Prentice-Hall, Inc. All rights reserved. 0-13-239227-5 Global Positioning of Nodes (1) Problem How can a single node efficiently estimate the latency between any two other nodes in a distributed system? E.g., find the closest server. Solution Construct a geometric overlay network, in which the distance d(P;Q) reflects the actual latency between P and Q.

16 Tanenbaum & Van Steen, Distributed Systems: Principles and Paradigms, 2e, (c) 2007 Prentice-Hall, Inc. All rights reserved. 0-13-239227-5 Global Positioning of Nodes (2) Computing a node’s position in a two-dimensional space. A node P needs d +1 landmarks to compute its own position in a d-dimensional space.

17 Tanenbaum & Van Steen, Distributed Systems: Principles and Paradigms, 2e, (c) 2007 Prentice-Hall, Inc. All rights reserved. 0-13-239227-5 Global Positioning of Nodes (3) Problems measured latencies to landmarks fluctuate computed distances will not even be consistent: Solution: Let the L landmarks measure their pairwise latencies d(b i ;b j ) and let each node P minimize a cost function by varying the number of dimensions.

18 Tanenbaum & Van Steen, Distributed Systems: Principles and Paradigms, 2e, (c) 2007 Prentice-Hall, Inc. All rights reserved. 0-13-239227-5 Election Algorithms Principle: An algorithm requires that some process acts as a coordinator. The question is how to select this special process dynamically. Note: In many systems the coordinator is chosen by hand (e.g. file servers). This leads to centralized solutions → single point of failure.

19 Tanenbaum & Van Steen, Distributed Systems: Principles and Paradigms, 2e, (c) 2007 Prentice-Hall, Inc. All rights reserved. 0-13-239227-5 The Bully Algorithm (1) Each process has an associated priority (weight). The process with the highest priority should always be elected as the coordinator. How do we find the heaviest process? 1.P sends an ELECTION message to all processes with higher numbers. 2.If no one responds, P wins the election and becomes coordinator. 3.If one of the higher-ups answers, it takes over. P’s job is done.

20 Tanenbaum & Van Steen, Distributed Systems: Principles and Paradigms, 2e, (c) 2007 Prentice-Hall, Inc. All rights reserved. 0-13-239227-5 The Bully Algorithm (2) (a) Process 4 holds an election (b) Processes 5 and 6 respond, telling 4 to stop. (c) Now 5 and 6 each hold an election.

21 Tanenbaum & Van Steen, Distributed Systems: Principles and Paradigms, 2e, (c) 2007 Prentice-Hall, Inc. All rights reserved. 0-13-239227-5 The Bully Algorithm (3) (d) Process 6 tells 5 to stop. (e) Process 6 wins and tells everyone.

22 Tanenbaum & Van Steen, Distributed Systems: Principles and Paradigms, 2e, (c) 2007 Prentice-Hall, Inc. All rights reserved. 0-13-239227-5 A Ring Algorithm (1) Process priority is obtained by organizing processes into a (logical) ring. Process with the highest priority should be elected as coordinator. Any process can start an election by sending an election message to its successor. If a successor is down, the message is passed on to the next successor. If a message is passed on, the sender adds itself to the list. When it gets back to the initiator, everyone had a chance to make its presence known. The initiator sends a coordinator message around the ring containing a list of all living processes. The one with the highest priority is elected as coordinator.

23 Tanenbaum & Van Steen, Distributed Systems: Principles and Paradigms, 2e, (c) 2007 Prentice-Hall, Inc. All rights reserved. 0-13-239227-5 A Ring Algorithm (2) Nodes that discover that the coordinator is down start election process. When the message comes back to the originator, a coordinator message is sent.

24 Tanenbaum & Van Steen, Distributed Systems: Principles and Paradigms, 2e, (c) 2007 Prentice-Hall, Inc. All rights reserved. 0-13-239227-5 Elections in Wireless Environments (1) Election algorithm in a wireless network, with node a as the source. (a) Initial network. (b)–(e) The build-tree phase

25 Tanenbaum & Van Steen, Distributed Systems: Principles and Paradigms, 2e, (c) 2007 Prentice-Hall, Inc. All rights reserved. 0-13-239227-5 Elections in Wireless Environments (2) Figure 6-22. Election algorithm in a wireless network, with node a as the source. (a) Initial network. (b)–(e) The build-tree phase

26 Tanenbaum & Van Steen, Distributed Systems: Principles and Paradigms, 2e, (c) 2007 Prentice-Hall, Inc. All rights reserved. 0-13-239227-5 Elections in Wireless Environments (3) (e) The build-tree phase. (f) Reporting of best node to source.

27 Tanenbaum & Van Steen, Distributed Systems: Principles and Paradigms, 2e, (c) 2007 Prentice-Hall, Inc. All rights reserved. 0-13-239227-5 Elections in Large-Scale Systems Requirements for superpeer selection: 1.Normal nodes should have low-latency access to superpeers. 2.Superpeers should be evenly distributed across the overlay network. 3.There should be a predefined portion of superpeers relative to the total number of nodes in the overlay network. 4.Each superpeer should not need to serve more than a fixed number of normal nodes. There are solutions for structured and unsctructured overly networks.


Download ppt "Tanenbaum & Van Steen, Distributed Systems: Principles and Paradigms, 2e, (c) 2007 Prentice-Hall, Inc. All rights reserved. 0-13-239227-5 DISTRIBUTED SYSTEMS."

Similar presentations


Ads by Google