Presentation is loading. Please wait.

Presentation is loading. Please wait.

Time in Embedded and Real Time Systems Lecture #6 David Andrews

Similar presentations


Presentation on theme: "Time in Embedded and Real Time Systems Lecture #6 David Andrews"— Presentation transcript:

1

2 Time in Embedded and Real Time Systems Lecture #6 David Andrews dandrews@eecs.ukans.edu

3 What We Will Cover Today Time and Order 1.Causal Order 2.Temporal Order 3.Delivery Order Measuring Time 1.Global Time 2.Precision/Accuracy 3.Sparse Time Clock Synchronization 1.Internal Synchronization 2.External Synchronization

4 Time and Order Time is relative… We can provide time ordering in different ways –Temporal (Think continuous timeline) Time period we are interested in is the duration Can develop ordering –If t a < t b, and t b < t c, then t a <t c. etc….. {T} is infinite ordered set of instants Event a takes place at an instant of time t a –Causal (directed dependency ordering) Can be used to find out “who done it”…. E 1 = the road ices E 2 = car slides on road E 1 -> E 2 However, E 2 cannot cause E 1 Causal events occur temporally –However, causal ordering focuses on cause -> effect, not time taken to occur Delivery Orders in distributed systems

5 Reference Clock Time is measured against a (theoretically perfect) clock called the reference clock. In actuality, the reference clock isn’t perfect ! Reference Clock (z clock) –External observers absolute time –Ideally, no error with “real world” time (Grennich or Zulu) –Frequency = f z, where 1/f z = 10 -15 (1 femtosecond) Quantization error not measurable Timestamping –Timestamp is value of clock for an observed event z(e) is absolute timestamp clock(e) value of system clock for event

6 Definitions Against Reference Clock Reference clock N k = #  ticks between two consecutive ticks of local clock 1 23 N k =10 Granularity (two definitions used in book) 1. N k in terms of #ticks 2. z(  tick i+1 ) – z(  tick i ) in terms of time

7 Physical Clocks Register counts up at  tick intervals –Quantization error set by frequency Linux = 10 msec  tick interval (resolution) 32 bit register encodes how much time ? 2 32 x 10 msec = 42949672 sec = 715827 minutes = 11930 hrs = 497 days

8 Physical Clock Errors - Drift Clock Drift: the drift of a physical clock k between  tick i and  tick i+1 is frequency ratio between physical clock and reference clock at instance of  tick i.

9 Real Drift Rates Ideal case not real world. Clocks actually drift….

10 Drift rate  k i Environmental changes can affect the crystal –Drift can be plus/minus –Take absolute value –Specs usually give maximum drift rate  k max –Typical specs of  k max = 10 -2 to 10 -7 sec/sec

11 Effects of Drift Drift can be additive on free running clocks Fc = 10 Mhz 1/fc = 10 -5 If clock drifts 10 -9 per clock, then you can miss a cycle every 10,000 clocks !

12 Precision and Accuracy Granularity Clock a = 10 Granularity Clock b = 10 Offset = #  ticks difference (example shows 3) Precision = max offset Precsion  offset

13 Time to standardize….. International Atomic Time (TAI – Temps Atomique Internationle) –1 sec == 9,192,631,770 periods of the radiation of a specified transition of the cesium atom 133. Universal Time Coordinated (UTC) –“Wall Clock” Time based on astronomical observations –Not perfect due to earths slightly less than perfect rotation –1 sec = TAI second –However, number of seconds in an hour must be modified by leap second January 1, 1958 TAI==UTC –Since then, UTC deviated by approx. 30 seconds

14 Global Time In distributed systems, we assume all are operating on clocks of same frequency. –We acknowledge clocks have certain drifts –We acknowledge clocks “start” at slightly different origins…. 1.Assume all clocks are accurate within precision  1.For any two clocks, |z(  tick j i –z(  tick k i ) | <  2.Reasonableness condition: g >  1.Says all granularities are larger than max offset (Precision  ) 3.If reasonableness condition met, then |t j (e) – t k (e)| <= 1 (t:= macrotick) 4.Says Observer May See 1 clock difference between same event measured by two different local clocks. Lets see….

15 Global Time Event a occurs at: –Macrotick 1 node a –Macrotick 1 node b –“Simultaneous event Event b occurs at: –Macrotick 1 node a –Macrotick 2 node b

16 Global Time a b c d e Event a occurs at mtick 5 Event b occurs at mtick 8 Both Reported as macrotick 1 Event c @ 21 Event d @29 Both Reported as macrotick 2 Event e @ 32

17 Global Time A occurs at  tick 28 B occurs at  tick 30 Clock i reports macrotick 3 for A Clock j reports macrotick 2 for B

18  /  Precedence Events are measured within , implying the same time Subsequent events must occur at least a duration of  0/1g, 0/2g no temporal order can be established 0/3g temporal order can be established 

19 Fundamental Limits of Time Measurement 1.Time stamps on two nodes for single event may differ by 1 tick. 1.Also, cannot impart temporal order on events that differ by only 1 tick 2.When measuring an interval (d obs ), the true duration d true is bounded by: (d obs – 2g) < d true < (d obs +2g) 3.Temporal order can be recovered by timestamps if difference >= 2 ticks 4.Temporal order can always be recovered if at least 0/3g

20 Internal Clock Synchronization Need to Guarantee that all clocks are within precision  Local clocks get “synch’ed” up periodically R int Convergence function  denotes offset of the time values immediately after resynchronization Drift offset max divergence of any two clocks (depends on R int and drift rate  of clock: Drift offset = 2  R int

21 Synchronization Criteria Ensemble of clocks can be synchronized if: –Convergence offset + drift <=  –Says best correction + allowable drift cannot wander out of precision range Need a Picture…..

22 Synchronization Techniques Central Master: –A node is designated master –Master sends value of time counter to all other (Slave) nodes –Slave Drift = master value – {current slave value +transit time} –Slave Corrects by drift value Distributed Synchronization –All nodes broadcast their time counter to all other nodes –Each node checks to see if within convergence criteria If not, node sleeps –All live nodes calculate correction and updates clock Different algorithms for doing this….

23 Global Time Jitter Assume node sends counter time to all other nodes –If delay for each node known, then correction is accurate –However, Jitter may occur Network congestion (usecs) Interrupt latencies (usecs) OS latencies (10 – 100 usecs) Application Software Latencies (500 usec – 5 msec) –Different techniques applied to reduce jitter in app layer

24 External Clock Synchronization Can broadcast a time message from global time server –Local clusters use previous techniques to synchronize


Download ppt "Time in Embedded and Real Time Systems Lecture #6 David Andrews"

Similar presentations


Ads by Google