150 likes | 372 Views
Time, Clocks, and the Ordering of Events in a Distributed System Leslie Lamport. Jaesub kim jskim@sslab.kaist.ac.kr. Contents. Partial Ordering Logical Clocks Total Ordering Anomalous Behavior Strong Clock Condition Physical Clock Condition Upper bound to avoid Anomalous Conclusion.
E N D
Time, Clocks, and the Ordering of Events in a Distributed SystemLeslie Lamport Jaesub kim jskim@sslab.kaist.ac.kr
Contents • Partial Ordering • Logical Clocks • Total Ordering • Anomalous Behavior • Strong Clock Condition • Physical Clock Condition • Upper bound to avoid Anomalous • Conclusion
“Happened before” relation • Smallest relation satisfying the three conditions: • If a and b are events in the same process and a comes before b, then ab • If a is the sending of a message by a process and b its receipt by another process then ab • If ab and b c then ac. • Logical Concurrency (of Events) • Two events are concurrent if neither can causally affect the other. • I.e. a b and b a
Logical Clocks • A clock is a way of assigning a number to an event. i.e. just a counter, no actual timing mechanism needed • Verify the clock condition: if ab then C<a> <C<b> and the two subconditions: • if a and b are events in process Pi and a comes before b, then Ci<a> <Ci<b>, • if a is the sending of a message by Pi and b its receipt by Pj then Ci<a><Cj<b>,
Implementation Rule • Each process Pi increments its clock Ci between two consecutive events, • If a is the sending of a message m by Pi then m includes a timestamp Tm = Ci<a> when Pj receives m, it sets its clock to a value greater than or equal to its present value and greater than Tm.
Defining a total order • We can define a total ordering on the set of all system events ab if either Ci<a><Cj<b> or Ci<a>=Cj<b> and Pi<Pj. • Ordering depends on the system of clocks Ci and is not unique
Computer A Computer B Anomalous Behavior • Logical clocks have anomalous behaviorsin the presence of outside interactions • Must use physical clocks d a X X outside interaction b e X X
Strong Clock Condition • Let S be set of all systems events plus the relevant external events • For any events a, b inS, if ab then C<a> <C<b> • The strong clock condition is not satisfied by our logical clocks. We turn to physical clocks
Physical Clock Conditions • There is a constant << 1 such that for all i: |d Ci(t)/dt - 1| < The clock is neither too fast nor too slow • There is a constant such that for all i, j: |Ci(t) - Cj(t)| < The clocks are more or less synchronized
How small and • To avoid anomalous: For any I, j and t Ci(t + ) –Cj(t) > 0 From PC1 , From PC2 and above condition
Implementation Rule for PC2 • If Pi does not receive a message at time tthen Ci(t) is differentiable and dCi(t)/dt> 0, • If Pi sends message m at time tthen m includes a timestamp Tm = Ci(t) When Pj receives m at time t’,itj sets Cj(t’) to maximum of Cj(t’-0) and Tm+.m,where .m is the minimum transmission delay
Conclusion • Concept of partial ordering and logical clock • Then, extending it to a arbitrary total ordering which is important for synchronization problem • Introduce anomalous behaviors and how to prevent it