1 / 31

Time ( and Global State )

Time ( and Global State ). Time – basics. We want to know when something happened - Physical and logical clocks. Algorithms may depend upon clock synchronization. No global notion of time. Time – system model. N processes: Each executes on a single processor. No shared memory.

nixie
Download Presentation

Time ( and Global State )

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. Time (and Global State)

  2. Time – basics • We want to know when something happened - Physical and logical clocks. • Algorithms may depend upon clock synchronization. • No global notion of time.

  3. Time – system model • N processes: • Each executes on a single processor. • No shared memory. • Only communication means is exchange of messages. • pi has state si. • An event is the occurrence of a single action, i.e.: • An internal state-transforming action by pi, or • a communication action. • e i e’ if e occurs before e’ in pi.

  4. Time – clocks • Each computer has its own physical clock. • The software clock Ci can be used to timestamp any event at pi. • Problems: Clock skew and clock drift.

  5. Time – Coordinated Universal Time (UTC) • International standard for timekeeping. • Based on atomic time. • Synchronizes with astronomical time using leap seconds. • UTC signals are synchronized and broadcast regularly from land-based radio stations and satellites. • Computers with receivers attached can synchronize their clocks with these timing signals.

  6. Synchronizing physical clocks – basics • External synchronization: For each i, synchronize Ci with an authoritative, external source of time. • Internal synchronization: For each i,j, synchronize Ci and Cj with each other. • Other issues: Correctness, monotonicity, faulty clocks, crash failures, arbitrary failures.

  7. Synchronizing physical clocks – in a synchronous system • Internal synchronization. • Sender sends local time t to receiver. • Receiver ideally sets time to: t + T(trans). • T(trans) in [min,max]. • Receiver sets time to: t + (max+min)/2.

  8. m r m t p Time server,S Synchronizing physical clocks – Cristian’s algorithm External synchronization p records total round-trip time T(round); p sets its time to t+T(round)/2; If minimal transmission time is known, accuracy can be calculated. Problem: single point of failure.

  9. Tserver Cristian’s algorithm Compensate for delays • Note times: • request sent: T0 • reply received: T1 • Assume network delays are symmetric server request reply client time T0 T1

  10. Tserver server request reply client time T0 T1 Cristian’s algorithm Client sets time to: = estimated overhead in each direction

  11. Error bounds If minimum message transit time (Tmin) is known: Place bounds on accuracy of result

  12. range = T1-T0-2Tmin Tmin Tmin Earliest time message arrives Latest time message leaves Error bounds Tserver server request reply client time T0 T1 accuracy of result =

  13. Cristian’s algorithm: example • Send request at 5:08:15.100 (T0) • Receive response at 5:08:15.900 (T1) • Response contains 5:09:25.300 (Tserver) • Elapsed time is T1 -T0 5:08:15.900 - 5:08:15.100 = 800 msec • Best guess: timestamp was generated 400 msec ago • Set time to Tserver+ elapsed time 5:09:25.300 + 400 = 5:09.25.700

  14. 200 200 Cristian’s algorithm: example If best-case message time=200 msec T0 = 5:08:15.100 T1 = 5:08:15.900 Ts = 5:09:25.300 Tmin = 200msec Tserver server request reply client time T0 T1 800 Error =

  15. Synchronizing physical clocks – the Berkeley algorithm • Internal synchronization. • A coordinator computer chosen to act as master. • Master periodically polls the other computers (the slaves). • Slaves send back their clock values to master. • Master calculates an average (taking the roundtrip times into account). • Master sends the amount by which each individual slave’s clock requires adjustment. • The algorithm eliminates readings from faulty clocks. • Algorithm has provisions for ignoring readings from clocks whose skew is too great, Compute a fault-tolerant average

  16. 3:25 2:50 9:10 3:00 Berkeley Algorithm: example 3:25 9:10 2:50 1. Request timestamps from all slaves

  17. 3:25 2:50 9:10 3:00 Berkeley Algorithm: example 3:25 9:10 2:50 2. Compute fault-tolerant average:

  18. 3:25 2:50 9:10 3:00 Berkeley Algorithm: example -0:20 -6:05 +0:15 3. Send offset to each client

  19. Synchronizing physical clocks – the Network Time Protocol (NTP) aims • Provide a service enabling clients across the Internet to be synchronized accurately to UTC. • Provide a reliable service that can survive lengthy losses of connectivity. • Enable clients to resynchronize sufficiently frequently to offset the rates of drift found in most computers. • Provide protection against interference with the time service, whether malicious or accidental.

  20. 1 2 2 3 3 3 Note: Arrows denote synchronization control, numbers denote strata. Synchronizing physical clocks – NTP architecture - A network of servers located across the Internet. - Primary servers connected directly to time source. - Secondary servers synchronized with primary servers. - Servers connected in logical hierarchy, synchronization subnet. - Three modes of sync.: Multicast, procedure-call, symmetric (H.W.).

  21. Server B T T i -2 i-1 Time m m' Time Server A T T i - 3 i Synchronizing physical clocks – NTP peers message exchange T(i-3): Time when previous message sent. T(i-2): Time when previous message was received. T(i-1): Time when this message (just received) was sent. T(i): Time when this message was received.

  22. SNTP Roundtrip delay: d = (T4-T1) - (T2-T3) T2 T3 server request reply client time T1 T4 Time offset:

  23. SNTP example Offset = ((800 - 1100) + (850 - 1200))/2 =((-300) + (-350))/2 = -650/2 = -325 Set time to T4 + t= 1200 - 325 = 875 T2=800 T3=850 server request reply time client T1=1100 T4=1200 Time offset:

  24. Cristian’s algorithm Offset = (1200 - 1100)/2 = 50 Set time to Ts + offset= 825 + 50 = 875 T2=800 T3=850 server request reply Ts=825 time client T1=1100 T4=1200

  25. Logical time and logical clocks – happened-before relation (self study) • If two events occurred at the same process pi, then they occurred in the order in which pi observes them (->i). • Whenever a message is sent between processes, the event of sending the message occurred before the event of receiving the message. • Transitive relation.

  26. Logical time and logical clocks – happened-before example (self study)

  27. Logical time and logical clocks – Lamport logical clocks and timestamps (self study) • A Lamport logical clock is a monotonically increasing software counter. • Each process pi keeps its own logical clock Li which is used to apply Lamport timestamps to events. • To capture the happened-before relation ->, processes update their logical clocks and transmit the values of their logical clocks in messages as follows: • Before each event at pi: Li := Li+1 • When pi sends a message m, it piggybacks t=Li. • When pj receives (m,t): Lj := max(Lj,t)+1. • e -> e’ => L(e) < L(e’).

  28. Logical time and logical clocks – Lamport timestamps example (self study)

  29. Logical time and logical clocks – Vector timestamps example (self study) Vi[i]: The number of events that pi has timestamped; Vi[j]: The number of events that have occurred at pj that pi has potentially been affected by, j <> i.

  30. Summary • Time • Synchronization of physical clocks: • In a synchronous system. • Cristian’s method. • The Berkeley algorithm. • The Network Time Protocol (NTP). • Logical time and logical clocks (self study): • The happened-before relation. • Lamport’s logical clocks and Lamport’s timestamps. • Vector timestamps.

More Related