Lamport’s Logical Clocks & Totally Ordered Multicasting
Reference L. Lamport, “Time, Clocks and the Ordering of Events in Distributed Systems,” Communications of the ACM, Vol. 21, No. 7, July 1978, pp. 558-565.
The Happened-Before Relation Lamport’s algorithm synchronizes logical clocks and is based on the happened-before relation: a b is read as “ a happened before b” The definition of the happened-before relation: If a and b are events in the same process and a occurs before b , then a b For any message m , send(m) send(m) rcv(m), where send(m) is the event of sending the message and rcv(m) is event of receiving it. If a , b and c are events such that a b and b c then a c
The Happened-Before Relation If two events, x and y , happen in different processes that do not exchange messages , then x y is not true, but neither is y x The happened-before relation is sometimes referred to as causality.
Lamport’s Algorithm We need a way of measuring time such that for every event a , we can assign it a time value C(a) on which all processes agree on the following: The clock time C must monotonically increase i.e., always go forward. If a b then C(a) < C(b) Each process, p, maintains a local counter C p The counter is adjusted based on the rules presented on the next page.
Lamport’s Algorithm 1. C p is incremented before each event is issued at process p : C p = C p + 1 2. When p sends a message m , it piggybacks on m the value t=C p 3. On receiving (m,t) , process q computes C q = max(C q ,t) and then applies the first rule before timestamping the event rcv(m) .
Example a b P1 P2 P3 c d e f g h i j k l Assume that each process’s logical clock is set to 0
Example a b P1 P2 P3 c d e f g h i j k l Assume that each process’s logical clock is set to 0 1 1 1 2 3 2 3 4 4 5 6 3
Example From the timing diagram on the previous slide, what can you say about the following events?
- Fall '16
- Order theory, UCI race classifications, Tour de Georgia, Total order, Total relation