CS555: Distributed Systems [Fall 2019] Dept. Of Computer Science , Colorado State University CS 555: D ISTRIBUTED S YSTEMS [T IME ] Shrideep Pallickara Computer Science Colorado State University CS555: Distributed Systems [Fall 2019] August 29, 2019 L2.1 Dept. Of Computer Science , Colorado State University Frequently asked questions from the previous class survey ¨ Quizzes/Exams? ¤ Frequency, etc. L2. 2 CS555: Distributed Systems [Fall 2019] August 29, 2019 Dept. Of Computer Science , Colorado State University Professor: S HRIDEEP P ALLICKARA L2.1 S LIDES C REATED B Y : S HRIDEEP P ALLICKARA
CS555: Distributed Systems [Fall 2019] Dept. Of Computer Science , Colorado State University Topics covered in this lecture ¨ Physical Clocks ¨ How time is actually measured ¨ Clock synchronization algorithms ¤ Network Time Protocol L2. 3 CS555: Distributed Systems [Fall 2019] August 29, 2019 Dept. Of Computer Science , Colorado State University Professor: S HRIDEEP P ALLICKARA S YNCHRONIZATION CS555: Distributed Systems [Fall 2019] August 29, 2019 L2.4 Dept. Of Computer Science , Colorado State University L2.2 S LIDES C REATED B Y : S HRIDEEP P ALLICKARA
CS555: Distributed Systems [Fall 2019] Dept. Of Computer Science , Colorado State University Synchronization ¨ Important that processes do not access a shared resource simultaneously ¤ Cooperate in granting each other temporary, exclusive access ¨ Multiple processes must sometimes need to agree on ordering of events ¤ Was m 1 from process P sent out before or after m 2 from process Q ? L2. 5 CS555: Distributed Systems [Fall 2019] August 29, 2019 Dept. Of Computer Science , Colorado State University Professor: S HRIDEEP P ALLICKARA What we will look at: ¨ Synchronization based on actual time ¨ Synchronization in which only relative ordering matters ¤ Rather than ordering in absolute time L2. 6 CS555: Distributed Systems [Fall 2019] August 29, 2019 Dept. Of Computer Science , Colorado State University Professor: S HRIDEEP P ALLICKARA L2.3 S LIDES C REATED B Y : S HRIDEEP P ALLICKARA
CS555: Distributed Systems [Fall 2019] Dept. Of Computer Science , Colorado State University Let’s look at a make example ¨ Large programs split up into multiple source files ¨ make examines times at which all source and object files were modified ¨ input.c (@ 2151) and input.o (@ 2150)? ¤ Input.c has changed since input.o was created ¨ output.c (@2144) and output.o (@2145)? ¤ No recompilation required L2. 7 CS555: Distributed Systems [Fall 2019] August 29, 2019 Dept. Of Computer Science , Colorado State University Professor: S HRIDEEP P ALLICKARA What could happen in a distributed system with make ? ¨ output.o (@2145) ¨ output.c modified right after that ¤ But assigned (@2144) by the machine ¨ No recompilation required ¤ Incorrect! ¤ Executable is a mix of object files from new and old sources L2. 8 CS555: Distributed Systems [Fall 2019] August 29, 2019 Dept. Of Computer Science , Colorado State University Professor: S HRIDEEP P ALLICKARA L2.4 S LIDES C REATED B Y : S HRIDEEP P ALLICKARA
CS555: Distributed Systems [Fall 2019] Dept. Of Computer Science , Colorado State University P HYSICAL C LOCKS CS555: Distributed Systems [Fall 2019] August 29, 2019 L2.9 Dept. Of Computer Science , Colorado State University Nearly all computers have a circuitry for tracking time ¨ Timer is a more precise term than clock ¨ Quartz crystals are kept under tension ¤ Oscillates at a well-defined frequency ¤ Frequency depends on: n Type and cut of crystal n The amount of tension L2. 10 CS555: Distributed Systems [Fall 2019] August 29, 2019 Dept. Of Computer Science , Colorado State University Professor: S HRIDEEP P ALLICKARA L2.5 S LIDES C REATED B Y : S HRIDEEP P ALLICKARA
CS555: Distributed Systems [Fall 2019] Dept. Of Computer Science , Colorado State University Each crystal has two registers associated with it ¨ {Counter, Holding Register} ¨ Each oscillation decrements the counter ¨ When counter reduces to zero ¤ Interrupt is generated: clock tick ¤ Counter reloaded from the holding register ¨ We can program the timer to generate interrupts N times per second L2. 11 CS555: Distributed Systems [Fall 2019] August 29, 2019 Dept. Of Computer Science , Colorado State University Professor: S HRIDEEP P ALLICKARA Measuring time ¨ Time is stored as number of ticks ¤ After some known starting date and time ¨ Stored in special battery-backed CMOS RAM L2. 12 CS555: Distributed Systems [Fall 2019] August 29, 2019 Dept. Of Computer Science , Colorado State University Professor: S HRIDEEP P ALLICKARA L2.6 S LIDES C REATED B Y : S HRIDEEP P ALLICKARA
CS555: Distributed Systems [Fall 2019] Dept. Of Computer Science , Colorado State University How the OS uses the timer to report actual time ¨ The OS reads the node’s hardware timer, H i (t) , scales it and adds an offset § C i (t) = α H i (t) + β ¤ This is the software clock ¨ In general, the clock is not completely accurate § C i (t) will always differ from t L2. 13 CS555: Distributed Systems [Fall 2019] August 29, 2019 Dept. Of Computer Science , Colorado State University Professor: S HRIDEEP P ALLICKARA On a single machine it is ok if the clock is off by a small amount ¨ All processes use the same clock ¨ Processes are internally consistent ¨ Only relative times matter in some cases L2. 14 CS555: Distributed Systems [Fall 2019] August 29, 2019 Dept. Of Computer Science , Colorado State University Professor: S HRIDEEP P ALLICKARA L2.7 S LIDES C REATED B Y : S HRIDEEP P ALLICKARA
CS555: Distributed Systems [Fall 2019] Dept. Of Computer Science , Colorado State University Things change when we add multiple clocks ¨ Frequency at which the quartz oscillator runs is fairly stable ¨ Impossible to guarantee that all oscillations are at the same frequency L2. 15 CS555: Distributed Systems [Fall 2019] August 29, 2019 Dept. Of Computer Science , Colorado State University Professor: S HRIDEEP P ALLICKARA This causes the (software) clocks to slowly get out of synch ¨ You get different values during read outs ¤ Clock skew ¨ Time is not independent of the machine on which it was reported L2. 16 CS555: Distributed Systems [Fall 2019] August 29, 2019 Dept. Of Computer Science , Colorado State University Professor: S HRIDEEP P ALLICKARA L2.8 S LIDES C REATED B Y : S HRIDEEP P ALLICKARA
CS555: Distributed Systems [Fall 2019] Dept. Of Computer Science , Colorado State University Physical and software clocks ¨ Multiple physical clocks are desirable ¤ Efficiency ¤ Redundancy ¨ How do we synchronize software clocks with: ¤ Real-world clocks ¤ Each other L2. 17 CS555: Distributed Systems [Fall 2019] August 29, 2019 Dept. Of Computer Science , Colorado State University Professor: S HRIDEEP P ALLICKARA Clock skew and drift ¨ The instantaneous difference between the readings of any two clocks is called their skew ¨ All clocks (including crystal-based ones) are subject to clock drift ¤ This means that they count time at different rates L2. 18 CS555: Distributed Systems [Fall 2019] August 29, 2019 Dept. Of Computer Science , Colorado State University Professor: S HRIDEEP P ALLICKARA L2.9 S LIDES C REATED B Y : S HRIDEEP P ALLICKARA
CS555: Distributed Systems [Fall 2019] Dept. Of Computer Science , Colorado State University Clock drift rates ¨ The drift rate is the change in the offset between the clock and a nominal perfect reference clock per unit of time ¤ Offset: Difference in reading ¨ Some typical drift rates: ¤ Regular Clocks based on quartz crystal n 10 -6 seconds/second n i.e. , 1 second every 1,000,000 seconds or 11.6 days ¤ High precision quartz clocks: 10 -7 seconds/second ¤ Atomic clocks: 10 -13 seconds/second L2. 19 CS555: Distributed Systems [Fall 2019] August 29, 2019 Dept. Of Computer Science , Colorado State University Professor: S HRIDEEP P ALLICKARA H OW TIME IS ACTUALLY MEASURED CS555: Distributed Systems [Fall 2019] August 29, 2019 L2.20 Dept. Of Computer Science , Colorado State University L2.10 S LIDES C REATED B Y : S HRIDEEP P ALLICKARA
CS555: Distributed Systems [Fall 2019] Dept. Of Computer Science , Colorado State University Since the invention of mechanical clocks, time has been measured astronomically ¨ Sun’s highest apparent position in the sky ¤ Transit of the sun ¤ At about noon each day ¨ Interval between consecutive transits of the sun ¤ Solar day ¨ Solar second? ¤ Solar day/86400 L2. 21 CS555: Distributed Systems [Fall 2019] August 29, 2019 Dept. Of Computer Science , Colorado State University Professor: S HRIDEEP P ALLICKARA But the earth’s rotation is not constant ¨ Proved in the 1940s ¨ Earth is slowing down ¤ Tidal friction ¤ Atmospheric drag ¨ Based on growth patterns on ancient corals ¤ 300 million years ago, we had 400 days per year L2. 22 CS555: Distributed Systems [Fall 2019] August 29, 2019 Dept. Of Computer Science , Colorado State University Professor: S HRIDEEP P ALLICKARA L2.11 S LIDES C REATED B Y : S HRIDEEP P ALLICKARA
Recommend
More recommend