1 / 111

Synchronization

Synchronization. Chapter 5. Synchronization. Has any one given any through to how time is kept? How do we keep the time reasonably correct on our own computers?. Synchronization. Why is time important?. Clock Synchronization.

guy-william
Télécharger la présentation

Synchronization

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Synchronization Chapter 5

  2. Synchronization • Has any one given any through to how time is kept? • How do we keep the time reasonably correct on our own computers?

  3. Synchronization • Why is time important?

  4. Clock Synchronization • When each machine has its own clock, an event that occurred after another event may nevertheless be assigned an earlier time.

  5. Time • What is time?

  6. Physical Clocks (1) • Computation of the mean solar day.

  7. Physical Clocks (2) • TAI seconds are of constant length, unlike solar seconds. Leap seconds are introduced when necessary to keep in phase with the sun.

  8. Clocks • Two clocks hardly ever agree. This difference is called clock skew.

  9. Problems with Maintaining Accurate Time • Timer accuracy, modern timer chips have relative tick rate errors of 10-5 which means that a timer that generates 60 ticks a second, generates 216,000 ticks an hour +/- 2 ticks. • This relative error is called the clock drift rate and manufacturers of clocks will specify a maximum drift rate for their clocks.

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

  11. Clock Synchronization • A computer can set its clock a number ways. It can use aGPS system (+/- 1msec) or a WWV radio receiver (+/- 3 to 10msec) or a Geostationary Operational Environmental Satellite (GOES +/- .1 msec) but typically it will use another computer on the network to obtain “correct” time.

  12. Problems with Maintaining Accurate Time • A problem with clocks getting time over the network has to do with the latency that occurs when one clock is used to set another clock. • This problem can be addressed by calculating the propagation time for the update. • The client knows when it sent the request and when it received the update relative to its own clock. Half this time is the approximate time for the time server to sent the update. The client can then correct the update by this amount.

  13. Cristian's Algorithm • Getting the current time from a time server.

  14. Christian’ Algorithm • The network delay can be calculated by (T1-T0)/2 • The new system time then becomes. • Tnew = Tserver + (T1-T0)/2

  15. Problems with Maintaining Accurate Time • A more serious problem is the actual correction and how it should be applied. • For example in an extreme case assume the current client time is 12:00:00pm and it gets an update from the time server that says the correct time is 11:59:48pm. What kinds of problems might occur if this time correction was applied immediately?

  16. Problems with Maintaining Accurate Time • Time changes should be applied gradually by whatever algorithm is in use. Otherwise problems such as makefile difficulties might occur when a clock is set back.

  17. Correcting Clocks • If a clock is too fast it has to be slowed down until it has the correct time. If it’s too slow it has to be sped up until it has the correct time. The adjustment is called a linear compensation function. Clocks should never go backwards.

  18. Berkley Algorithm • In Christian’s algorithm the time server is passive, in the Berkley algorithm the time server is active. • This algorithm uses a polling technique to get times from all participating servers. From these times an average is computed which the time server uses to slow down or speed up the time on participating systems.

  19. The Berkeley Algorithm • The time daemon asks all the other machines for their clock values • The machines answer • The time daemon tells everyone how to adjust their clock

  20. Synchronization • Has any one heard of NTP or Network Time Protocol?

  21. NTP • How does it work and how accurate is it?

  22. NTP • Enable clients across the Internet to be accurately synchronized to UTC (universal coordinated time) despite message delays. Statistical techniques are used for filtering data and gauging the quality of the results. • Provide a reliable service that can survive lengthy losses of connectivity. This means having redundant paths and redundant servers. • Enable clients to synchronize frequently and offset the effects of clock drift. • Provide protection against interference; authenticate that the data is from a trusted source.

  23. NTP • The ntpd program is an operating system daemon which sets and maintains the system time of day in synchronism with Internet standard time servers. • Check any UNIX box that is an important server and it either has ntpd running or uses rdate set up in a crontab.

  24. NTP • Christian’s Algorithm and the Berkley algorithm are intended for intranet configurations. NTP is a time protocol designed for the Internet. • NTP has an accuracy of 1-50msec worldwide.

  25. NTP • NTP servers are divided up into different categories. • Primary servers are connected to external, accurate UTC clocks. • Secondary servers are synchronized with the primary servers. • The NTP configuration of servers is hierarchical.

  26. NTP UTC source -Atomic Clock Accurate 1 Primary Server Stratum 1 2 2 Secondary Server Stratum 2 3 3 3 Stratum 3 Less accurate W/S Workstations and servers

  27. NTP • NTP servers synchronize using one of 3 modes. • Multicast mode • Used in high-speed LAN, achieves low accuracy levels • Procedure-call • Similar to Christian’s algorithm, suitable for higher accuracies than multicasting. • Symmetric mode • Achieves the highest level of accuracy, usually implemented in low strata numbers (used between redundant servers). In this mode pairs of time servers with a know association exchange times.

  28. NTP • In all modes messages are delivered unreliably using standard UDP protocol. • In the procedure-call and symmetric mode servers exchange messages, each message is time stamped with the local time of the last send and receive and the time of the current send and receive. • There are therefore 4 times.

  29. NTP Ti-1 Ti-2 Server B Time m’ m Time Server A Ti-3 Ti Four times for messages m and m’

  30. NTP • For each pair of messages sent between the two servers NTP The client now has four time stamps. From this it can determine the round-trip delay and clock offset. • Let a = Ti-2 – Ti-3and b = Ti – Ti-1Round-trip delay, D = a - b andClock offset, O = (a+b)/2 • O is therefore an estimate of the offset between the clocks a D is a measure of the accuracy of this estimate.

  31. NTP • To successive pairs of offsets and delay times <O,D> NTP calculates the quality of this estimate statistical using a filter dispersion method. • Dispersion: A measure, in seconds, of how scattered the time offsets have been from a given time server.

  32. Logical Clocks • When we write and execute message passing applications is the actual time important?

  33. Logical Clocks • Sometimes actual time is important but most time at least for scientific computational application we are concerned with the sequence of events. • What really matters is the order in which event occurred. • A logical clock is a clock that can generate sequence numbers that make sense system wide.

  34. Lamport • Lamport developed a “happens before” notation expressed as a->b meaning a happens before b. • If a is a message sent and b is the message received then a must be before b. • Likewise if a->b and b->c then a->c (transitive)

  35. Lamport • The importance of measuring time is to assign a time value to each event on which everyone will agree on the final order of events. • Thus if, a->b then clock(a) < clock(b), but if a and b occur on different processes that don’t exchange messages then a->b is not true. We then say that these events are concurrent.

  36. Lamport In 3 of the 6 messages (c,d and f) time is moving back. If we sort the message by depart timestamp the order is a,b,e,d,c,f instead of a,b,c,d,e,f • Consider the sequence of events depicted below

  37. Lamport • Lamportユs algorithm remedies the situation as follows: • Each message carries a timestamp of the sending time (according to the sender’s clock). • When a message arrives and the receiverユs clock is less than the timestamp on the received message, the system’s clock is forwarded to the message’s timestamp + 1. Otherwise nothing is done.

  38. Lamport • If we apply this algorithm to the same sequence of messages, we can see that message ordering is now preserved. Note that between every two events, the clock must tick at least once.

  39. Lamport • Lamport’s algorithm needs a monotonically increasing software counter for a “clock” that has to be incremented at least when events that need to be time stamped take place. • For any two events a->b, L(a) < L(b) where L(x) represents the Lamport timestamp for x.

  40. Lamport • For the sequence of events in the figure we can conclude that a->b and c->d because events within a process are sequenced. • b->c and d->f because Lamport imposes a • send(m)->receive(m) relationship • a->e and e->a because these events are concurrent.

  41. Problems with Lamport • It is possible that pairs of distinct events can have the same Lamport time stamp. To overcome this problem the process ID is utilized. • Therefore we define a global logical timestamp as (Ti,i) where Ti is the Lamport timestamp and i the process ID. • We then conclude that • (Ti,i) < (Tj,j) if and only if • Ti < Tj • or Ti = Tp and i<j • Of course this is arbitrary since there is no physical evidence of the process ordering, but it does insure no two Lamport timestamps are the same.

  42. Problems with Lamport • Given that L(e) < L(e’) can we conclude a casual relationship between e and e’ such that e->e’ • The answer is no we can’t, unless we introduce the concept of vector clocks.

  43. Vector Clock • A vector clock in a system of N processes is a vector of N integers. • Each process maintains its own vector clock (Vi for process Pi) to timestamp local events. • Like timestamps, vector timestamps (the vector of N integers) are sent with each message.

  44. Vector Clock Rules • The vector is initialized to 0 for all processes Vi[j]=0 for i,j=1,…,N • Before a Process Pi timestamps an event, it increments its element of the vector in its local vector. Vi[i] = Vi[i]+1 • A message is sent from process Pi with Vi attached to the message. • When process Pj receives vector timestamp t, it compares the two vectors element by element setting its local vector clock to the higher of the two values. Vj[i] = max(Vj[i],t[i]) for i=1,…,N

  45. Vector Clock • We compare two vector timestamps by defining; • V = V’ iff V[j] = V’[j] for j = 1,…N • V < V’ iff V[j] < V’[j] for j = 1,…,N • For any two events e,e’ if e->e’ then V(e_ < V(e’) which is the same for Lamport’s algorithm • With vector clocks we now have the condition that if V(e) < V(e’) the e->e’ • Two events are concurrent if neither V(e)<= V(e’) nor V(e’) <= V(e).

  46. Vector Clock • We can see that a->f because (1,0,0) <= (2,2,2) • But we can also see that c is concurrent with e because neither • (0,0,1) < (2,1,0) nor (2,1,0 < (0,0,1)

  47. Global State • What is a global state?

  48. Global State • It is the local state of each process, together with the messages that are currently in transit. • What is the local state?

  49. Global State • Chandy and Lamport introduced the notion of a distributed snapshot as a means for recording the global state. • The notion of a global state is illustrated in the following slide.

  50. Global State (1) • A consistent cut • An inconsistent cut

More Related