Download presentation
Presentation is loading. Please wait.
Published byEvan Wilson Modified over 9 years ago
1
TIME, CLOCKS AND THE ORDERING OF EVENTS IN A DISTRIBUTED SYSTEM L. Lamport Computer Science Laboratory SRI International
2
THE PAPER Addresses the problem of clock drift in distributed systems Identify main function of computer clocks to order events Indicates which conditions clocks must satisfy to fulfill their role Introduces logical clocks
3
ORDERING EVENTS Event ordering linked with concept of causality : –Saying that event a happened before event b is same as saying that event a could have affected the outcome of event b –If events a and b occur on processes that do not exchange any data, their exact ordering is not important
4
Relation “has happened before” (I) Smallest relation satisfying the three conditions: –If a and b are events in the same process and a comes before b, then a b –If a is the sending of a message by a process and b its receipt by another process then a b –If a b and b c then a c
5
Example (I) Process i Process k Process jX X X X X a c b d e
6
Example (II) From first condition – a d – c e From second condition – a c – b e From third condition – a e
7
Relation “has happened before” (II) We cannot always order events: relation “has happened” before is only a preorder If a did not happen before b, it cannot causally affect b
8
Logical clocks Verify the clock condition : if a b then C and the two subconditions: –if a and b are events in process P i and a comes before b, then C i –if a is the sending of a message by P i and b its receipt by P j then C i
9
Implementation rules Each process P i increments its clock C i between two consecutive events, If a is the sending of a message m by P i then m includes a timestamp T m = C i when P j receives m, it sets its clock to a value greater than or equal to its present value and greater than T m
10
Defining a total order We can define a total ordering on the set of all system events a b if either C i or C i = C j and P i < P j This ordering is not unique
11
Anomalous behaviors Logical clocks have anomalous behaviors in the presence of outside interactions –Carrying a flash drive from one machine to another –Dictating file changes over the phone Must use physical clocks
12
Example Process i Process k Process jX X X X X a c b d e outside interaction
13
Strong clock condition Let S be set of all systems events plus the relevant external events For all events a, b in S, if a b then C ( a ) < C ( b )
14
Physical clock conditions There is a constant << 1 such that for all i : | d C i (t) / dt - 1 | < The clock is neither too fast nor too slow There is a constant such that for all i, j : | C i (t) - C j (t) | < The clocks are more or less synchronized
15
Implementation rules If P i does not receive a message at time t then C i (t) is differentiable and dC i (t)/dt > 0 If P i sends message m at time t then m includes a timestamp T m = C i (t) When P j receives m at time t’, it sets C j (t’) to maximum of C j (t’ -0 ) and T m + m, where m is the minimum transmission delay
16
Observations Like logical clocks, physical clocks cannot be rolled back Required accuracy of a given physical clock depends on the minimum transmission delay of outside interactions –If it takes 20 minutes to carry a flash drive between two machines, their clocks can be off by up to 20 minutes
17
Example Process i Process jX X X 11:30 am d OK 11:15 am X 11:30 am NO
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.