1 / 31

Time

Time. This powerpoint presentation has been adapted from: www.cse.buffalo.edu/~bina/cse486/.../TimeGlobalStatesApr20.ppt. Contents. Introduction Clocks , events and process states Synchronizing physical clocks Logical time & logical clocks. Contents. Introduction

kamea
Télécharger la présentation

Time

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 This powerpoint presentation has been adapted from: www.cse.buffalo.edu/~bina/cse486/.../TimeGlobalStatesApr20.ppt

  2. Contents • Introduction • Clocks, events and process states • Synchronizing physical clocks • Logical time & logical clocks

  3. Contents • Introduction • Clocks, events and process states • Synchronizing physical clocks • Logical time & logical clocks

  4. Time • Introduction • Why time is important in distributed systems? • A quantity that needs to be measured accurately • to know at what time of day a particular event occurred at a particular computer • is important for auditing purposes • to maintain the consistency of distributed data

  5. Contents • Introduction • Clocks, events and process states • Synchronizing physical clocks • Logical time & logical clocks

  6. Time • Clocks, events and process states • How to timestamp events in terms of their execution? • Consider the following notations • ϸ • A collection of N processes pi, i = 1,2, .. N (p executes on a single processor) • si • The state of pi (each p has a state, the state changed when it is executed) • Actions of pi • Operations that transform pi’s state (p executes with a series of actions. • Send or receive message between pi

  7. Time • Clocks, events and process states • e • Event: occurrence of a single action • Relation between the events(i) • The series of events for a single process p • e.g., eie` : e occurs before e` at pi • history(pi ) = hi= <ei0, ei1, ei2, …> • The series of event e in process pi

  8. Time • Clocks, events and process states • How to timestamp the events (e)? • Clock in computer: • Each computer has its own physical clock • Is a device that counts oscillations occurring in a crystal at a definite frequency • The OS reads the node’s hardware time: Hi(t) • The counts of oscillation since an original point • Then, scale it and add offset to produce software clock, Ci(t) = Hi(t)+ • To timestamp of an event

  9. Time • Clocks, events and process states • Computer clocks tend not to be in a perfect agreement. • Clock drift • Clocks count time at different rates • Clock skew • The instantaneous (direct) difference between the readings of any two clocks • Why? Oscillators are subject to physical variations • Frequency, temperature

  10. Time • Clocks, events and process states • How to synchronize computer clocks? • Use external source that provide highly accurate time • Use atomic oscillator • Used by International Atomic Time

  11. Time • Clocks, events and process states • What is the international standard for time keeping? • Coordinated Universal Time (UTC) • Based on atomic time • Time is coordinated with astronomical time • UTC signal is broadcasted from land-based radio station to satellites covering many parts of the world

  12. Contents • Introduction • Clocks, events and process states • Synchronizing physical clocks • Logical time & logical clocks

  13. Time • Synchronizing physical clocks • How to know at what time of the day an event occurs? • Two types of synchronization: • External • Internal • Notations: • Ci: pi’s clock • I : an interval of real time

  14. Time • Synchronizing physical clocks • External synchronization • For a synchronization bound D > 0, and for a source S of UTC time, |S(t)-Ci(t)| < D, for i= 1, 2, … N and for all real times t in I • Clocks Ci are accurate to within the bound D • Internal synchronization • For a synchronization bound D > 0, |Ci(t)-Cj(t)| < D for i, j =1,2, … N, and for all real times t in I • Clocks Ciagree within the bound D • Clocks that are internally synchronized are not necessarily externally synchronized • If the system ϸ is externally synchronized with a bound D, then the same system is internally synchronized with a bound of 2D.

  15. t t + min t +Ttrans t+max Time • Synchronizing physical clocks • Synchronization in a synchronous system • there will be a minimum time of transmission where no other processes executed at the same time and no other network traffic existed. • Maximum time of transmission in synchronous mode is always set (i.e., time out is applied) • Protocol • Sender: send M(t) • Receiver: set time to t + Ttrans • Bounds are known in synchronous system • min < Ttrans < max (constant) • Optimum transmission time, • Ttrans = (min+max) / 2 • Receiver’s clock = t + (min+max) / 2

  16. Time • Synchronizing physical clocks • The common practice in distributed system is asynchronous; • The factors lead to message delay are not bounded (no upper bound max) • The Internet is asynchronous • Ttrans = min + x, where x ≥ 0, the value of x is not known • Methods for synchronizing clock in asynchronous distributed systems: • Cristian’s method • The Berkeley algorithms • The Network Time Protocol

  17. m r m t p Time server,S Time • Synchronizing physical clocks • Cristian’s method of synchronizing clocks • Use time server • Protocol • mr– process p requests the time from server • mt – process receives the time (t is inserted in the message) • Tround - process p records the round-trip (send request-get reply) • Estimated time: t + Tround/2

  18. t + min t +Tround-min t t +Tround/2 t +Tround Time • Synchronizing physical clocks • Cristian’s method of synchronizing clocks • Accuracy analysis • If the minimum delay of a message transmission is min, then accuracy: (Tround/2 – min)

  19. Time and Global State • Synchronizing physical clocks • The Berkeley algorithms • Internal synchronization using a coordinator computer (master). Other computers that their clocks need to be synchronized is known as slaves • The master polls the slaves’ clocks • The master estimates the slaves’ clocks by round-trip time • The master averages the slaves’ clock values • The master sends back to the slaves the amount that the slaves’ clocks should adjust • Slave adjust its clock

  20. Time • Synchronizing physical clocks • The Network Time Protocol (NTP) • An architecture for a time service and a protocol to distribute time information over the Internet • Aims: • External synchronization • Enable clients across the Internet to be synchronized accurately to UTC • Reliability • Can survive lengthy losses of connectivity • Redundant server & redundant path between servers • Scalability • Enable clients to resynchronize sufficiently frequently to offset the rates of drift found in most computers • Security • Protect against interference with the time service

  21. Time • Synchronizing physical clocks • NTP service is provided by servers located across the Internet • Primary servers are connected directly to a time source, e.g. radio clock receiving UTC • Secondary servers are synchronized to primary servers

  22. 1 2 2 3 3 3 Note: Arrows denote synchronization control, numbers denote strata. Time • Synchronizing physical clocks • Network Time Protocol Architecture

  23. Source: Wikipedia

  24. Time • Synchronizing physical clocks • 3 modes of NTP synchronization: • Multicast mode • Intended for use on a high speed LAN • One or more servers multicast the time to other servers in the LAN • Low accuracy but sufficient • Procedure-call mode • Similar to Christian’s • Higher accuracy than multicast • Symmetric mode • Use by the servers that supply time information in LANs • The highest accuracy

  25. Contents • Introduction • Clocks, events and process states • Synchronizing physical clocks • Logical time & logical clocks

  26. Time • Logical time and logical clocks • Events in a single process is ordered uniquely by times shown in the local clock • Clock is unable to be synchronized perfectly. Hence physical time is not accurate to determine the occurrence of events

  27. Time • Logical time and logical clocks • Happened-before relation • It is also sometimes known as the relation of causal ordering or potential causal ordering.

  28. Time • Logical time and logical clocks • Logical clocks- a simple mechanism to capture HB order numerically. Known as Lamport timestamps algorithm (it is a software counter). • LC1 • Li is incremented before each event is issued at process pi : Li :=Li+1 • LC2: (a) When a process pi sends a message m, it adjoin the value t = Li on m (b) On receiving (m,t), a process Pj computes Lj := max(Lj, t) and then applies LC1 before timestamping the event receive(m)

  29. Time • Logical time and logical clocks • Totally ordered logical clocks algorithm Assumption Ti: local timestamp of e that is an event occurring at pi Tj: local timestamp of e` that is an event occurring at pj The timestamps of two events eand e` are (Ti, i), (Tj, j) When (Ti, i) < (Tj, j), if and only if Ti< Tj, or Ti = Tjand i < j

  30. Time • Logical time and logical clocks • Vector Clocks algorithm • Each process pi keeps a vector clock Vi VC1: Initially, Vi[j]=0, for i, j = 1,2…, N VC2: Just before pi timestamps an event, it sets Vi[i] := Vi[i] +1 VC3: pi includes the value t= Vi in every message it sends VC4: When pi receives a timestamp t in a message, it sets Vi[j] :=max(Vi[j], t[j]), for j=1,2…,N

  31. End of the Chapter…

More Related