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 Synchronization

2 Tanenbaum & Van Steen, Distributed Systems: Principles and Paradigms, 2e, (c) 2007 Prentice-Hall, Inc. All rights reserved. 0-13-239227-5 Outline Synchronization –E.g., make file –Need for cooperation –Single machine vs distributed system –Clock synchronization –Resource mutual exclusion –Global positioning –Election

3 Tanenbaum & Van Steen, Distributed Systems: Principles and Paradigms, 2e, (c) 2007 Prentice-Hall, Inc. All rights reserved. 0-13-239227-5 Clock Synchronization a case of make Centralized system When each machine has its own clock, an event that occurred after another event may nevertheless be assigned an earlier time.

4 Tanenbaum & Van Steen, Distributed Systems: Principles and Paradigms, 2e, (c) 2007 Prentice-Hall, Inc. All rights reserved. 0-13-239227-5 Outline Clock synchronization –Relative syn vs absolute syn (to real time) –Fine syn vs loose syn Time and clock –Physical clock –GPS example Clock syn algorithms –NTP –Berkeley alg –Reference broadcast syn Global positioning Lamport’s logical clocks

5 Tanenbaum & Van Steen, Distributed Systems: Principles and Paradigms, 2e, (c) 2007 Prentice-Hall, Inc. All rights reserved. 0-13-239227-5 Physical Clocks (1) Timer: Machined quartz crystal, Counter and holding register Clock tick – interruptions Clock skew - difference in time value –Systems run at slightly different rate. N computers –How to syn them to real world clock ? –How to syn them with each other ?

6 Tanenbaum & Van Steen, Distributed Systems: Principles and Paradigms, 2e, (c) 2007 Prentice-Hall, Inc. All rights reserved. 0-13-239227-5 Solar time Figure 6-2. Computation of the mean solar day. A solar day: the interval between two consecutive transits of the sun. Then, the solar second.

7 Tanenbaum & Van Steen, Distributed Systems: Principles and Paradigms, 2e, (c) 2007 Prentice-Hall, Inc. All rights reserved. 0-13-239227-5 Atomic Clocks (2) TAI (International Atomic Time) seconds are of constant length, unlike solar seconds. Leap seconds are introduced when necessary to keep in phase with the sun.

8 Tanenbaum & Van Steen, Distributed Systems: Principles and Paradigms, 2e, (c) 2007 Prentice-Hall, Inc. All rights reserved. 0-13-239227-5 Universal Coordinated Time UTC (TAI + leap)– the standard (replacing GMT) Allow all the systems to syn to it e.g., electric power (frequency), computer software NIST (National Institute of Standard Time) SW radio Satellites also provides UTC

9 Tanenbaum & Van Steen, Distributed Systems: Principles and Paradigms, 2e, (c) 2007 Prentice-Hall, Inc. All rights reserved. 0-13-239227-5 Global Positioning System GPS – global positioning system Provides geographical positions 29 satellites, each has 4 atomic clocks. A satellite broadcasts its position, time stamps its message with its local time. A receivers calculates its position using only three satellites. Real world facts that complicate GPS 1.It takes a while before data on a satellite’s position reaches the receiver. 2.The receiver’s clock is generally not in synch with that of a satellite.

10 Tanenbaum & Van Steen, Distributed Systems: Principles and Paradigms, 2e, (c) 2007 Prentice-Hall, Inc. All rights reserved. 0-13-239227-5 Global Positioning System (1) Figure 6-4. Computing a position in a two-dimensional space.

11 Tanenbaum & Van Steen, Distributed Systems: Principles and Paradigms, 2e, (c) 2007 Prentice-Hall, Inc. All rights reserved. 0-13-239227-5 Calculate Position With accurate system deviation and measurement: Ti: Satellite Timestamp, Tnow: receiver’s current time, Dr: receiver time deviation Di: delay, Di = (Tnow – Ti) +Dr di: real signal travel distance, di = c (Tnow – Ti) Measured travel distance: c Di = di +c Dr. known (xi, yi, xi), unknowns (x, y, z, Dr): di = sqrt((xi –x)^2 + (yi –y)^2 +(zi –z)^2). c Di = di +c Dr Four satellites can provide also accurate time in addition to position.

12 Tanenbaum & Van Steen, Distributed Systems: Principles and Paradigms, 2e, (c) 2007 Prentice-Hall, Inc. All rights reserved. 0-13-239227-5 Outline Synchronization –E.e., make file Time and clock –Physical clock –GPS example Clock syn –NTP –Berkeley –Reference broadcast syn Global positioning Lamport’s logical clocks

13 Tanenbaum & Van Steen, Distributed Systems: Principles and Paradigms, 2e, (c) 2007 Prentice-Hall, Inc. All rights reserved. 0-13-239227-5 Clock Synchronization Algorithms The relation between clock time and UTC when clocks tick at different rates. Skew: Frequency of p’s clock Offset to the standard Maximum drift rate -- the extent that the frequency drifts ( = frequency -1) offset Frequency

14 Tanenbaum & Van Steen, Distributed Systems: Principles and Paradigms, 2e, (c) 2007 Prentice-Hall, Inc. All rights reserved. 0-13-239227-5 Network Time Protocol Getting the current time from a time server B. Or the offset to B’s time

15 Issue of clock adjustment 1.If A is slower, make it to the current server time 2.If A is quicker, clocks do not go backward. 1.Slow down the future ticking little by little, until eventually synchronized. Tanenbaum & Van Steen, Distributed Systems: Principles and Paradigms, 2e, (c) 2007 Prentice-Hall, Inc. All rights reserved. 0-13-239227-5

16 NTP Time servers divided into strata Level 0 the clock Level 1, the server has the clock is stratum #1 -- the WWV … If B is a stratum #k server, A becomes a stratum # (k+1) High levels syn to lower levels Server is passive, waiting and respond to contacts from lower level.

17 Tanenbaum & Van Steen, Distributed Systems: Principles and Paradigms, 2e, (c) 2007 Prentice-Hall, Inc. All rights reserved. 0-13-239227-5 The Berkeley Algorithm (1) Figure 6-7. (a) The time daemon asks all the other machines for their clock values. The Berkeley Algorithm turns passive to active - -- server pulls clients.

18 Tanenbaum & Van Steen, Distributed Systems: Principles and Paradigms, 2e, (c) 2007 Prentice-Hall, Inc. All rights reserved. 0-13-239227-5 The Berkeley Algorithm (2) Figure 6-7. (b) The machines answer.

19 Tanenbaum & Van Steen, Distributed Systems: Principles and Paradigms, 2e, (c) 2007 Prentice-Hall, Inc. All rights reserved. 0-13-239227-5 The Berkeley Algorithm (3) Figure 6-7. (c) The time daemon tells everyone how to adjust their clock.

20 Tanenbaum & Van Steen, Distributed Systems: Principles and Paradigms, 2e, (c) 2007 Prentice-Hall, Inc. All rights reserved. 0-13-239227-5 Wireless networks Synchronization among nodes based on a reference clock. Reference Broadcast Syn. (RBS) Reference node broadcast a message (single hop) Each node records local time of receiving the message Exchange the record with peers Calculate its offset with respect to each peer. (mutual, relative offset) Not necessary to adjust clock.

21 Tanenbaum & Van Steen, Distributed Systems: Principles and Paradigms, 2e, (c) 2007 Prentice-Hall, Inc. All rights reserved. 0-13-239227-5 Clock Synchronization in Wireless Networks (1) Figure 6-8. (a) The usual critical path in determining network delays.

22 Tanenbaum & Van Steen, Distributed Systems: Principles and Paradigms, 2e, (c) 2007 Prentice-Hall, Inc. All rights reserved. 0-13-239227-5 Clock Synchronization in Wireless Networks (2) Figure 6-8. (b) The critical path in the case of RBS.

23 RBS Issues: –Average over multiple messages with the same peer in calculating each other’s offset to the reference time –Clocks drift apart when time goes by, Offset will increase. Compensate with linear regression Offset [p,q](t) = a t + b. Tanenbaum & Van Steen, Distributed Systems: Principles and Paradigms, 2e, (c) 2007 Prentice-Hall, Inc. All rights reserved. 0-13-239227-5

24 Outline Synchronization –E.e., make file Time and clock –Physical clock –GPS example Clock syn –NTP –Berkeley –Reference broadcast syn Global positioning Lamport’s logical clocks

25 Tanenbaum & Van Steen, Distributed Systems: Principles and Paradigms, 2e, (c) 2007 Prentice-Hall, Inc. All rights reserved. 0-13-239227-5 Geometric Overlay networks –Errors –triangle inequality

26 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) Figure 6-18. Computing a node’s position in a two-dimensional space.

27 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) Figure 6-19. Inconsistent distance measurements in a one-dimensional space.

28 Tanenbaum & Van Steen, Distributed Systems: Principles and Paradigms, 2e, (c) 2007 Prentice-Hall, Inc. All rights reserved. 0-13-239227-5 Outline Synchronization –E.e., make file Time and clock –Physical clock –GPS example Clock syn –NTP –Berkeley –Reference broadcast syn Global positioning Lamport’s logical clocks

29 Tanenbaum & Van Steen, Distributed Systems: Principles and Paradigms, 2e, (c) 2007 Prentice-Hall, Inc. All rights reserved. 0-13-239227-5 Lamport’s Logical Clocks (1) The "happens-before" relation → can be observed directly in two situations: If a and b are events in the same process, and a occurs before b, then a → b is true. If a is the event of a message being sent by one process, and b is the event of the message being received by another process, then a → b

30 Tanenbaum & Van Steen, Distributed Systems: Principles and Paradigms, 2e, (c) 2007 Prentice-Hall, Inc. All rights reserved. 0-13-239227-5 Lamport’s Logical Clocks (2) Figure 6-9. (a) Three processes, each with its own clock. The clocks run at different rates.

31 Tanenbaum & Van Steen, Distributed Systems: Principles and Paradigms, 2e, (c) 2007 Prentice-Hall, Inc. All rights reserved. 0-13-239227-5 Lamport’s Logical Clocks (3) Figure 6-9. (b) Lamport’s algorithm corrects the clocks.

32 Tanenbaum & Van Steen, Distributed Systems: Principles and Paradigms, 2e, (c) 2007 Prentice-Hall, Inc. All rights reserved. 0-13-239227-5 Lamport’s Logical Clocks (4) Figure 6-10. The positioning of Lamport’s logical clocks in distributed systems.

33 Tanenbaum & Van Steen, Distributed Systems: Principles and Paradigms, 2e, (c) 2007 Prentice-Hall, Inc. All rights reserved. 0-13-239227-5 Lamport’s Logical Clocks (5) Updating counter C i for process P i 1.Before executing an event P i executes C i ← C i + 1. 2.When process P i sends a message m to P j, it sets m’s timestamp ts (m) equal to C i after having executed the previous step. 3.Upon the receipt of a message m, process P j adjusts its own local counter as C j ← max{C j, ts (m)}, after which it then executes the first step and delivers the message to the application.


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