Presentation is loading. Please wait.

Presentation is loading. Please wait.

1. Explain why synchronization is so important in distributed systems by giving an appropriate example When each machine has its own clock, an event that.

Similar presentations


Presentation on theme: "1. Explain why synchronization is so important in distributed systems by giving an appropriate example When each machine has its own clock, an event that."— Presentation transcript:

1 1. Explain why synchronization is so important in distributed systems by giving an appropriate example When each machine has its own clock, an event that occurred after another event may nevertheless be assigned an earlier time.

2 2.Give an example of how mutual exclusion can be implemented in distributed systems. Mutual Exclusion: A Centralized Algorithm Process 1 asks the coordinator for permission to enter a critical region. Permission is granted Process 2 then asks permission to enter the same critical region. The coordinator does not reply. When process 1 exits the critical region, it tells the coordinator, when then replies to 2

3 A Distributed Algorithm
The process that want to enter a critical region builds a message containing the name of the critical region it wants to enter, its process number, and the current time. Send the message to all other processes and itself. For the process receives a request message, it will act in three different ways: If the receiver is not in the critical region and does not want to enter it, it sends back an OK message to the sender. If the receiver is already in the critical region, it does not reply. Instead, it queues the request. If the receiver wants to enter the critical region but has not yet done so, it compares the timestamp in the incoming message with the one contained in the message that it has sent everyone. The lowest one wins. If the incoming message is lower, the receiver sends back an OK message. If its own message has a lower timestamp, the receiver queues the incoming request and sends nothing.

4 A Distributed Algorithm
Two processes want to enter the same critical region at the same moment. Process 0 has the lowest timestamp, so it wins. When process 0 is done, it sends an OK also, so 2 can now enter the critical region.

5 A Toke Ring Algorithm An unordered group of processes on a network.
A logical ring constructed in software.

6 3. Describe the underlying model for clock synchronization algorithms
All the algorithms have the same underlying model of the system, which will be describe bellow: When UTC time is t, the value of the clock on machine p is Cp(t). In a perfect world, we would have Cp(t) = t for all p and all t, that is dC/dt=1. Real timer do not interupt exactly H times a second as supposed. There must be a relative error. If there exists some constant c such that : 1-c < dC/dt < 1+c That constant c is specified by the manufacturer and is known as the maximum drift rate If two clocks are drifting from UTC in opposite direction, at a time Dt after they synchronized, they may be as much as 2c Dt apart. If the system designers want to guarantee that no two clocks ever differ by more than d, clock must be resynchronized (in software) at least every d /2c seconds

7 Clock Synchronization Algorithms
The relation between clock time and UTC when clocks tick at different rates.

8 Getting the current time from a time server.
4. Describe how Cristian’s clock synchronization algorithm can be implemented. How to deal with the two problems of this algorithm? Getting the current time from a time server. Sender set it time to CUTC after get reply from server, there are two problems for this algorithm: Major one is that time must never run backward. Change can be introduce gradually Minor one is that there it takes a nonzero amount of time for the timer server’s reply to get back to the sender.

9 5. In Lamport’s Algorithm, every event is assigned a local clock time, we call it timestamp. This algorithm also introduced a happens-before relation. According to this algorithm, what conditions we should follow when we assign time to all events? Use Lamport’s algorithm, we should assign time to all events in a distributed system subject to the following conditions: If a happens before b in the same process, C(a)<C(b) If a and b represent the sending and receiving of a message, respectively, C(a)<C(b). For all distinctive events a and b, C(a)≠C(b).

10 6.Tell the reason why inconsistent cut happen when we deal with the global state of a distributed system. A consistent cut An inconsistent cut

11 7.Describe how the bully algorithm works for the coordinator election.
Distributed algorithms usually require one process to act as coordinator, initiator, or otherwise perform some special role. The election algorithms are used for electing a coordinator. The goal of an election algorithm is to ensure that when an election starts, it concludes with all processes agreeing on who the new coordinator is to be. The Bully Algorithm: When any process notices that the coordinator is no longer responding to requests, it initiates an election. A process, p, holds and election as follows: P sends an ELECTION message to all processes with higher numbers. If no one responds, P wins the election and becomes coordinator If one of the higher-ups answers, it takes over. P’s job is done.

12 The Bully Algorithm (1) The bully election algorithm
Process 4 holds an election Process 5 and 6 respond, telling 4 to stop Now 5 and 6 each hold an election

13 Process 6 wins and tells everyone
The Bully Algorithm (2) Process 6 tells 5 to stop Process 6 wins and tells everyone

14 8.Describe how the ring algorithm works for the coordinator election.
Election algorithm using a ring.


Download ppt "1. Explain why synchronization is so important in distributed systems by giving an appropriate example When each machine has its own clock, an event that."

Similar presentations


Ads by Google