150 likes | 258 Views
Synchronization. Chapter 5. Clock Synchronization. When each machine has its own clock, an event that occurred after another event may nevertheless be assigned an earlier time. Physical Clocks (1). Computation of the mean solar day. Physical Clocks (2).
E N D
Synchronization Chapter 5
Clock Synchronization • When each machine has its own clock, an event that occurred after another event may nevertheless be assigned an earlier time.
Physical Clocks (1) • Computation of the mean solar day.
Physical Clocks (2) • TAI (International Atomic Time) seconds are of constant length, unlike solar seconds. • Leap seconds are introduced when necessary to keep in phase with the sun.
Clock Synchronization Algorithms • The relation between clock time and UTC (Universal Coordinated Time) when clocks tick at different rates.
Cristian's Algorithm • Getting the current time from a time server.
Cristian's Algorithm • Two problems: • Time must never run backwards, so backwards changes must be introduced gradually • update clock more slowly, for example • The delay for the time to get back may be large, and may be unpredictable (have to subtract propagation time) • Can measure several times and take average • Can omit values that exceed some threshold • Can take only the smallest, since this may be most representative of pur propagation time
The Berkeley Algorithm • The time daemon asks all the other machines for their clock values • The machines answer • The time daemon tells everyone how to adjust their clock
Lamport Timestamps • Three processes, each with its own clock. The clocks run at different rates. • Lamport's algorithm corrects the clocks.
Lamport Timestamps • In 1978, Leslie Lamport noticed that for most applications synchronization is not important, but only that events be ordered in time. • Lamport defined some concepts: • 1) if a and b are events in the same process, and a occurs before b, then ab "a happened before b" • 2) if a is the event of sending a message and b is the event of • receipt of that message, then ab
Lamport Timestamps • 3) if ab and bc then ac • Sometimes we draw a space-time diagram • time -----> • ---------- a ------------- b ------------------------- Process p1 • ------------- c ---- d -------------- g -------------- Process p2 • ------------------- e --------------------- f -------- Process p3
Lamport Timestamps • ---------- a ------------- b ------------------------- Process p1 • ------------- c ---- d -------------- g -------------- Process p2 • ------------------- e --------------------- f -------- Process p3 • Suppose there are messages from c to b, d to f, and e to g • cb • df • eg • dg • cd ==> cf
Lamport Timestamps • ---------- a ------------- b ------------------------- Process p1 • ------------- c ---- d -------------- g -------------- Process p2 • ------------------- e --------------------- f -------- Process p3 • two events a and b are said to be concurrent if it is not true that ab and it is not true that ba • d and e are concurrent
Example: Totally-Ordered Multicasting • An application of Lamport timestamps: • Updating a replicated database and leaving it in an inconsistent state.
Example: Synchronization with Event Counts and Sequencers • Paper by D. P. Reed and R. K. Kanodia, ``Synchronization with Eventcounts and Sequencers,'' Communications of the ACM, 22, 2 (February 1979), pp.115-123