260 likes | 826 Views
Time ,Clocks and Ordering of Events in a Distributed System. Author: Leslie Lamport CS 5204 Operating Systems Ajit Kulkarni. Need for Clocks. Synchronization in Distributed Systems Utilize timers implementation? accuracy? Do we need timers? ‘what happened before what?’.
E N D
Time ,Clocks and Ordering of Events in a Distributed System Author: Leslie Lamport CS 5204 Operating Systems Ajit Kulkarni
Need for Clocks • Synchronization in Distributed Systems • Utilize timers • implementation? • accuracy? • Do we need timers? • ‘what happened before what?’
History Behind Paper • The Maintenance of Duplicate Databases by Paul Johnson and Bob Thomas • Use of timestamps • Incorrect algorithm
Special Relativity • No invariant total ordering of events in space-time • Different observers can disagree about which of two events happened first • Partial order in which an event e1 precedes an event e2e1 can causally affect e2
Partial Ordering in Computer Systems • Uniprocess a and b , events in the same process, and a comes before b, then a b • Multiprocess First process sends message :event a ,second process receives it :eventb then a b • Transitivity If a b and b c then a c
Goals of Paper • Not to rely on global time • Order events based on logical clocks
Special cases of Ordering • Concurrent Events • Independent input and output • No causal order • Happens before relation • Events a and ba->b implies a happens before b • a can causally affect b
Process i Process k Process j Example (I) d a X X c e X X b X
Results • From first condition • ad • ce • From second condition • ac • be • From third condition • ae
Do we need clocks? • Two independent events…NO • Two dependent events …YES but • Can we do better than timers
Logical Clocks • A counter attached to each process • Counter updates after every new event • Achieves partial ordering • System of Clocks: Function C which assigns to any event b the number C(b), where C(b) = Cj(b)
Clock Condition • For any events a,b :if ab then C(a) < C(b) • Satisfying conditions: • If Ci(a)<Ci(b) implies a comes beforeb • Ci(a) < Cj(b) implies b received message from a where i, j are different
System of clocks satisfying conditions • Process increments counter between two successive events • Between 2 processes • Process sends message with a timestamp • On receiving message process sets counter to value greater (its timestamp ,value in message)
Total Ordering • One common order for everyone • A relation ==>,a ==>b if and only if either • Ci(a) < Ci(b) or • Ci(a) = Cj(b) and Pi < Pj • If ab then a==>b
Anomalous Behaviors • Seen in logical clocks with external interactions
Process i Process k Process j Example (II) a X c e X X b d X X
Results • Process i sends message to process k a->d • Process i sends external message to process j a->c • Process i sends message to process k c->b • Resource granted to process j
Strong Clock Condition • For any events a,b in S if ab then C(a) < C(b) where S is set of all system events and external events
Mutual exclusion example • Process granted the resource must release it before it can be granted to another process • Different requests for the resource must be granted in the order in which they are made • If every process granted the resource eventually releases it, then every request is eventually granted
Physical Time • C i(t) =>clock Ci at physical time t • Conditions for being a true physical clock • derivative is 1 • all clocks nearly same
Central Ideas • A precise characterization of causality in distributed systems • a framework for explaining and reasoning about event ordering in distributed protocols
Further Research Led by Paper • Vector and matrix clock abstractions • Stable and non stable predicate detection • Shows distributed systems as fundamentally different from other concurrent systems • Byzantine agreement • Byzantine clock synchronization and ordered multicast protocols