Presentation is loading. Please wait.

Presentation is loading. Please wait.

Time This powerpoint presentation has been adapted from: 1)www.cse.buffalo.edu/~bina/cse486/.../TimeGlobalState sApr20.ppt.

Similar presentations


Presentation on theme: "Time This powerpoint presentation has been adapted from: 1)www.cse.buffalo.edu/~bina/cse486/.../TimeGlobalState sApr20.ppt."— Presentation transcript:

1 Time This powerpoint presentation has been adapted from: 1)www.cse.buffalo.edu/~bina/cse486/.../TimeGlobalState sApr20.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  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  Introduction

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

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

7 Time e Event: occurrence of a single action Relation between the events(  i ) The series of events for a single process p e.g., e  i e` : e occurs before e` at p i history(p i ) = h i = The series of event e in process p i  Clocks, events and process states

8 Time  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: H i (t) » The counts of oscillation since an original point Then, scale it and add offset to produce software clock, C i (t) =  H i (t)+  » To timestamp of an event  Clocks, events and process states

9 Time  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  Clocks, events and process states

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

11 Time  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  Clocks, events and process states

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

13 Time  How to know at what time of the day an event occurs? Two types of synchronization: External Internal Notations: C i : p i ’s clock I : an interval of real time  Synchronizing physical clocks

14 Time  External synchronization For a synchronization bound D > 0, and for a source S of UTC time, |S(t)-C i (t)| < D, for i = 1, 2, … N and for all real times t in I Clocks C i are accurate to within the bound D  Internal synchronization For a synchronization bound D > 0, |C i (t)-C j (t)| < D for i, j =1,2, … N, and for all real times t in I Clocks C i agree 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.  Synchronizing physical clocks

15 Time  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 + T trans Bounds are known in synchronous system min < T trans < max (constant) Optimum transmission time, T trans = (min+max) / 2 Receiver’s clock = t + (min+max) / 2  Synchronizing physical clocks t t+maxt +T trans t + min

16 Time  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 T trans = 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  Synchronizing physical clocks

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

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

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

20 Time  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  Synchronizing physical clocks

21 Time  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  Synchronizing physical clocks

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

23 Source: Wikipedia

24 Time  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  Synchronizing physical clocks

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

26 Time  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  Logical time and logical clocks

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

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

29 Time  Totally ordered logical clocks algorithm Assumption T i : local timestamp of e that is an event occurring at p i T j : local timestamp of e` that is an event occurring at p j The timestamps of two events e and e` are (T i, i), (T j, j) When (T i, i) < (T j, j), if and only if T i < T j, or T i = T j and i < j  Logical time and logical clocks

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

31 End of the Chapter…


Download ppt "Time This powerpoint presentation has been adapted from: 1)www.cse.buffalo.edu/~bina/cse486/.../TimeGlobalState sApr20.ppt."

Similar presentations


Ads by Google