Presentation is loading. Please wait.

Presentation is loading. Please wait.

Time, Clocks and the Ordering of Events in a Distributed System - by Leslie Lamport.

Similar presentations


Presentation on theme: "Time, Clocks and the Ordering of Events in a Distributed System - by Leslie Lamport."— Presentation transcript:

1 Time, Clocks and the Ordering of Events in a Distributed System - by Leslie Lamport

2 Outline Partial Ordering Logical Clocks Total Ordering External Factors Physical Clocks Conclusions

3 Partial Ordering Partial Ordering : The smallest relation -> on the set of events of a system satisfying : –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 one process and b is the receipt of the same message by another process, then a->b. –If a->b and b->c then a->c. Causality –If a -> b, then event a can affect event b. –I.e. b comes after (or depends on results of) event a.

4 Partial Ordering Logical Concurrency (of Events) –Two events are concurrent if neither can causally affect the other. –I.e. a-->b and b-->a. Note : –a-->a. We assume that it is impossible to construct systems where an event can happen before itself. –Hence -> is an irreflexive partial ordering on the set of all events in the system.

5 Partial Ordering

6 Examples Time increases upward. P1 and P2 are causal. (within a process) P3 and Q3 are concurrent. (causally independent). [note that this is the case even though fig 1 seems to imply that Q3 occurs before P3] P1 are R4 are causally dependent. Only upon exchanging messages can we know regarding the ordering of events in the system.

7 Logical Clocks At this point, we are only considering only Logical Clocks. A clock is a way of assigning a number to an event. i.e. just a counter, no actual timing mechanism needed. No relation of between the counter and physical time. The “system” clock is the union of all clocks maintained by all the processes in the system.

8 Logical Clocks

9 Clock Condition :For any events a, b: –if a->b then C(a) < C(b). Converse condition need NOT hold. C1: If a and b are events in process P i, and a comes before b, then C i (a) < C i (b). C2 : If a is the sending of a message by process P i and b is the receipt of that message by process P k, then C i (a) < C k (b).

10 Logical Clocks In terms of “ticks”, this means that : –tick line between events of a process. –tick line between messages across processes. –tick is NOT an event. In terms of implementation, this means : –IR1 : Each process P i increments C i between any two successive events. –IR2 : If event a is the sending of a message m by process P i then the message m contains a time-stamp T m = C i (a). Upon receiving a message m, process P k sets C k greater than or equal to its present value and greater than T m.

11 Logical Clocks

12 Total Ordering Extension of Partial Ordering. Break ties using the < relation between processes. This is a way of assigning priorities to processes. Definition :If a is an event in process P i and b is an event in process P k, then a=>b if and only if either C i (a) < C k (b) or C i (a) = C k (b) and P i < P k Ordering depends on the system of clocks C i and is not unique. Only the partial ordering is uniquely determined by the system of events.

13 Partial v/s Total Ordering by Examples

14 Total Ordering Total ordering is important and useful in implementing a distributed system. Mutex example. Centralized scheduling will (may ?) not work. Distributed Algorithm. Problems : –algorithm requires active participation of all processes. (since to operate, each process needs to learn about operations of all processes). Failure of a single process will halt the system. –How to distinguish between pause and failure ?

15 External Factors Messages external to the system can cause anomalies.[banking example]. New System  (contains all external factors). New ordering operator :  Strong Clock Condition :For any events a, b in  : –If a  b then C(a) < C(b). The strong clock condition is not satisfied by our logical clocks. We turn to physical clocks...

16 Physical Clocks But physical clocks are not exactly synchronized and run at different rates (although the rate differential is extremely small). So, we need to adjust them ever so often to keep them “loosely synchronized” (I.e. keep them from drifting very far apart) atleast to a level that can allow the system to disambiguate ordering of events. Above parameters related to , the minimum time between events. Specialized rules IR1 and IR2 for physical clocks.

17 Conclusions Happened Before defines a Partial Ordering of events (arising from causal relationships). Giving priorities to processes can convert this to a Total Ordering. A centralized algorithm may not work. A Distributed algorithm has a “single point of failure” (process) ! Even Total Ordering can break down due to events external to the system. Physical clocks can help, but they must be “loosely synchronized” and must be reset forward when they drift far apart. Minimum time between events defines the granularity of “drift far apart”.


Download ppt "Time, Clocks and the Ordering of Events in a Distributed System - by Leslie Lamport."

Similar presentations


Ads by Google