PA160: Net-Centric Computing II. Time Synchronization Luděk Matýska Faculty of Informatics Masaryk University Spring 2016 Luděk Matýska (Fl MU) 4. Time Synchronization Spring 2016 1 / Time on a single node Timer (clock) • Oscillating quartz crystal 9 Counter • Each oscillation decreases the counter value • Interrupt when zero Each individual interrupt is a tick • Holding register • Counter initiation after interrupt 9 Stored time increased after each interrupt Luděk Matýska (Fl MU) 4. Time Synchronization Spring 2016 2 /1 Distributed computer systems <* Each node has its own timer • Time is not automatically synchronized • Clock skew • Relation to the absolute time 9 Problems • Internode synchronization • Absolute time synchronization Luděk Matýska (Fl MU) 4. Time Synchronization Spring 2016 3 /1 Absolute time • Original (old) definition of the time unit • 1 second equals 1/86 400 solar day • Current definition of the time unit—atomic clock • Electronic transition frequency of the electromagnetic spectrum of atoms o Cesium-133 standard in 1955 • Chip-scale atomic clock in 2004 (125 mW) • 1 second equals 9192 631770 cycles (transitions between two energ levels of Cs-133) • International atomic clock • Average measurement of around 50 world laboratories Luděk Matýska (Fl MU) 4. Time Synchronization Spring 2016 niversal Coordinated Time, UTC • Atomic and solar times are not synchronized • Leap second needed • Compensation for the irregularities of Earth rotation • Added whenever difference between atomic clock and mean solar time gets 800 ms • Result is the Universal Coordinated Time (UTC) • GMT replacement a UTC globally synchronized Luděk Matýska (Fl MU) 4. Time Synchronization Spring 2016 5 / Clock synchronization • Basic assumptions • A set of nodes with their own clocks/timers • Interrupt frequency H Hz Cp(t) is the time measured by clock at node p • Ideally Cp(t) = t for all p • Real behavior: If there exists p such as i-p<^* b is transitive • Events x and y are concurrent iff nor x —>* y nor y —>* x holds Luděk Matýska (Fl MU) 4. Time Synchronization Spring 2016 13/1 Implementation • Each process does have its own logical clock • For events within any particular process the relation "happens-before" is trivially fulfilled • Interprocess synchronization is the result of message passing • Each message contains time stamp 7~s of the sender (its time of sending the message) • If internal receiver time Tr is lower (i.e. "younger") than the time of sending the message (7~s), we put Tr = 7~s + 1 • Additional condition • No two events happen at the same time Luděk Matýska (Fl MU) 4. Time Synchronization Spring 2016 14 / Summary • Lamport's algorithm is sufficient to define and keep a global (logica time in a distributed system • Properties • If a happens before b in the same process, C(a) < C(b) • If a is sending and b receipt of the same message, C(a) < C(b) • For all events a, b such that a ^ b, C(a) 7^ C(b) holds • The algorithms provides global (partial) order on events in a distributed system • First published in 1978 in CACM; one of the most cited articles in Computer Science of all time Luděk Matýska (Fl MU) 4. Time Synchronization Spring 2016