Top Banner

of 59

Introduction Clocks,events and process states Synchronizing physical clocks

Mar 16, 2016

ReportDownload

Documents

lilith

Chapter 10: Time and Global States. Introduction Clocks,events and process states Synchronizing physical clocks Logical time and logical clocks Global states Distributed debugging Summary. Introduction. Time is an important issue in DS Need to measure accurately - PowerPoint PPT Presentation

  • IntroductionClocks,events and process statesSynchronizing physical clocksLogical time and logical clocksGlobal statesDistributed debuggingSummaryChapter 10: Time and Global States

  • Time is an important issue in DSNeed to measure accuratelyE.g. auditing in e-commerce Algorithms depending onE.g. consistency, makeNo universe physical clockNewtons opinionEinsteins Relativity TheoryPeoples approachesApproximately synchronizeLogical clocksCapture causality between eventsIntroduction

  • IntroductionClocks,events and process statesSynchronizing physical clocksLogical time and logical clocksGlobal statesDistributed debuggingSummaryChapter 10: Time and Global States

  • A collection of N processes pi, i = 1,2, .. NsiThe state of piE.g. variablesActions of piOperations that transform pis stateSend or receive message between pj eEvent: occurrence of a single actionioccur before in pi , e.g. e i e`Total order of events in pihistory(pi ) = hi = Model of a distributed system

  • Clock in computerA device that count oscillations occurring in a crystal at a definite frequencyhardware time: Hi(t)Relative time Software time: Ci(t) = Hi(t)+Timestamp of event Clock skew and clock driftSkew: the instantaneous difference between the readings of any two clocksDrift: crystal oscillate at different rateCant avoid clock driftexampleClocks

  • Standard secondAtomic oscillator (International Atomic Time)Drift rate: one part in 10139,192,631,770 periods of transition between the two hyperfine levels of the ground state of Cs133Since 1967Astronomical timeRotation of earth on its axis and about the SunSkew between astronomical time and atomic timeCoordinated Universal Time (UTC)Atomic time which is inserted a leap second occasionally to keep in step with astronomical timeBroadcast UTC to the WorldE.g., by GPS or WWVCoordinated Universal Time

  • IntroductionClocks,events and process statesSynchronizing physical clocksLogical time and logical clocksGlobal statesDistributed debuggingSummaryChapter 10: Time and Global States

  • Ci : pis clock, I: an interval of real timeExternal synchronizationFor 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 IClocks Ci are accurate to within the bound DInternal synchronizationFor a synchronization bound D > 0, |Ci(t)-Cj(t)| < D for i, j =1,2, N, and for all real times t in IClocks Ci agree within the bound DIf accurate to within D, then agree within 2DExternal & Internal synchronization

  • Correctness of a hardware clock HA bounded drift rate , e.g. 106 seconds/second(1 - )(t - t) C(t) Set clock backErrors in the make Change the clock rateClock failuresCrash failure: stop tickingArbitrary failure, e.g. Y2K bugGeneral synchronization measures

  • ProtocolSender: send M(t)receiver: set time to t + TtransBounds are know in synchronous system min < Ttrans < max So, set Ttrans = (min+max) / 2Receiver clock = t + (min+max) / 2Clock skew (max min ) / 2Synchronization in a synchronous system

  • Application circumstanceC/S Round-trip time is short compared with the required accuracyProtocolmr, mt, TroundEstimated time: mt + Tround/2Accuracy analysisIf the minimum delay of a message transmission is min, then accuracy: (Tround/2 min)Cristians method of synchronizing clocks

  • Internal synchronizationProtocolmaster poll slaves clocksmaster estimate slaves clocks by round-trip timeSimilar to Christians algorithmAverage the slaves clock valuesCancel out the individual clocks tendencies to run fast or slowSend back to the client the amount that the clients clock should adjust byPositive or negative valueAvoid further uncertainty due to the message transmission timeThe Berkeley algorithms

  • External synchronizationenable clients across the Internet to be synchronized accurately to UTCReliabilitycan survive lengthy losses of connectivityRedundant server & redundant path between serversScalabilityEnable clients to resynchronize sufficiently frequently to offset the rates of drift found in most computersSecurityProtect against interference with the time serviceDesign aims of Network Time Protocol

  • ArchitectureReconfigure as servers become unreachableSynchronization measuresMulticast modeIntend for use on a high speed LANAssuming a small delayLow accuracy but efficientProcedure-call modeSimilar to Christianshigher accuracy than multicastSymmetric modeThe highest accuracyNetwork Time Protocol

  • Protocol, highest accuracySymmetric mode synchronizationAssummingt, t: actual transmission time of m, m; o: actual Bs clock skew relative to AWe haveTi-2 = Ti-3 + t + o , Ti = Ti-1 + t oThendi = t + t = Ti-2 Ti-3 + Ti Ti-1 o = oi +(t-t)/2 where oi= (Ti-2 Ti-3 + Ti-1 Ti ) /2Estimated time: oiAccuracy analysisDue t, t >=0, then oi - di /2
  • ImplementationNTP servers retain eight most recent pairs The value oi of that corresponds to the minimum value di is chosen to estimate oA NTP server exchange with several peers in addition to with parentPeers with lower stratum numbers are favouredPeer with the lowest synchronization dispersion are favouredSymmetric mode synchronization continued

  • IntroductionClocks,events and process statesSynchronizing physical clocksLogical time and logical clocksGlobal statesDistributed debuggingSummaryChapter 10: Time and Global States

  • HB1: If process pi: eie`, then ee`HB2: For any message m, send(m) receive(m)HB3: IF e, e`and e`` are events such that e e` and e` e``, then e e``Causal ordering or potential causal orderingExamplea || eShortcomingsNot suitable to processes collaboration that does not involve messages transmissionCapture potential causal orderingHappen-before relation

  • Lamport timestamps algorithmLC1: Li is incremented before each event is issueed at process pi : Li :=Li+1LC2: (a) When a process pi sends a message m, it piggybacks on m the value t = Li; (b) On receiving (m,t), a process Pj computes Lj := max(Lj, t) and then applies LC1 before timestamping the event receive(m)e e` L(e) < L(e`)L(e) < L(e`) e e` or e||e`ExampleLogical Clock

  • Useful in some applicationsTotally ordered logical clocksAssummingTi : local timestamp of e that is an event occuring at piTj : local timestamp of e` that is an event occuring at pjDefine the timestamps of e, e` are (Ti, i), (Tj, j)Define =V(sj)[i] for i,j = 1,2,, NIf one processs state depends upon another, the global state also encompasses the state upon which it dependsObserving consistent global states

  • Example of consistent global states and inconsistent global statesTwo processes manage to maintain |x1-x2|
  • Evaluating possibly There is a downwards way in which there is a state evaluated to True by Evaluating definitely There is no downwards way in which there is not a state evaluated to True by ExampleIf evaluates to True in the state at level 5, then definitely If evaluates to false in the state at level 5, then possibly Evaluating possibly and definitely

  • Asynchronous systemsHigh time costTo find consistent global state S = (s1, s2, , sn), the monitor Should examine any two local states si and sjSynchronous systems|Ci(t)-Cj(t)| < D for i,j = 0, 1,, NAlgorithm modificationThe observed process sends vector time and physical time with the event to the monitorMonitor find consistency stateV(si)[i]>=V(sj)[i] si and sj should occurred at the same real timeEvaluating possibly and definitely in synchronous systems

  • IntroductionClocks,events and process statesSynchronizing physical clocksLogical time and logical clocksGlobal statesDistributed debuggingSummaryChapter 10: Time and Global States

  • Clock skew, clock driftSynchronize physical clocksChristians algorithmBerkeley algorithmNetwork Time ProtocolLogical timeHappen-before relationLamport timestamp algorithmVector clockSummary

  • Global statesConsistent cut, consistent stateSnapshot algorithmConstruct reachability relationship by snapshotGlobal debuggingThe monitor collects distributed events with vector timestamp Construct reachability relationshipExamine possibly and definitely Summary continued

  • Skew between computer clocks in a DS

  • Clock synchronization using a time server

  • An example synchronization subnet in an NTP implementation

  • Messages exchanged between a pair of NTP peers

  • Events occurring at three processes

  • Lamport timestamps for the events

  • Vector timestamps for the events

  • Detecting global properties

  • Cuts

  • The snapshot algorithmMarker receiving rule for process pi On pis receipt of a marker message over channel c:if (pi has not yet recorded its state) itrecords its process state now;records the state of c as the empty set;turns on recording of messages arriving over other incoming channels;else pi records the state of c as the set of messages it has received over c since it saved its state.end ifMarker sending rule for process piAfter pi has recorded its state, for each outgoing channel c: pi sends one marker message over c (before it sends any other message over c).

  • Pi has record its state?Pi has not recorded its statePi has recorded its state

  • Reachability between states in the snapshot algorithm

  • Find pre-snap events and post-snap events1. The snapshot is consistent global states that record a set of events that occurred on some processes2. Approach: Swap ej that should belong to post-snap events and ej+1 that should belong to pre-snap events according to the snap3. AnalysisThis situation could not happen if ej ej+1 Since if ej+1 belongs to the pre-snap ev