1 / 17

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

Time, Clocks and the Ordering of Events in a Distributed System - by Leslie Lamport. Outline. Partial Ordering Logical Clocks Total Ordering External Factors Physical Clocks Conclusions. Partial Ordering.

keran
Download Presentation

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

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

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. Logical Clocks • 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 Pi, and a comes before b, then Ci(a) < Ci(b). • C2 : If a is the sending of a message by process Pi and b is the receipt of that message by process Pk, then Ci(a) < Ck(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 Pi increments Ci between any two successive events. • IR2 : If event a is the sending of a message m by process Pi then the message m contains a time-stamp Tm = Ci(a). Upon receiving a message m, process Pk sets Ck greater than or equal to its present value and greater than Tm.

  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 Pi and b is an event in process Pk, then a=>b if and only if either Ci(a) < Ck(b) or Ci(a) = Ck(b) and Pi < Pk • Ordering depends on the system of clocks Ci 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 m, 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”.

More Related