Lamppost’s& vectors logical
BY-PINKI KUMARI SONI
• A logical clock is a mechanism for capturing chronological and causal
relationships in a distributed system. Distributed systems may have no
physically synchronous global clock, so a logical clock allows global
ordering on events from different processes in such systems.
• Note- chronological: the relation of a serial to its predecessors and successors
• Casual-Causation indicates that one event is the result of the occurrence of the other event;
i.e. there is a causal relationship between the two events.
LOGICAL CLOCK USE AND
• Logical clocks are useful in computation analysis, distributed algorithm design,
individual event tracking, and exploring computational progress.
• Some noteworthy logical clock algorithms are:
• Lamport’s timestamps, which are monotonically increasing software counters.
• Vector clocks, that allow for partial ordering of events in a distributed system.
Timestamp-a digital record of the time of occurrence of a particular event.
• Lamport’s clocks are a simple technique used for determining the order of
events in a distributed system.
• This clock was proposed by Leslie Lamport , a Lamport clock maintains order
of operations by incrementing a counter contained in the events
• By simply adding a counter value to events as they are received and
incrementing this value based on the last seen value,
• Lamport clocks provide a partial ordering of events – specifically “happened-
LAMPORT’S ALGORITHM FOLLOWS
SOME SIMPLE RULES:
• A process increments its counter before each event in that process;
• When a process sends a message, it includes its counter value with the message;
• On receiving a message, the counter of the recipient is updated, if necessary, to the greater
of its current counter and the timestamp in the received message. The counter is then
incremented by 1 before the message is considered received.
The algorithm for sending:
• time = time+1;
• time_stamp = time;
• send(message, time_stamp);
The algorithm for reciving:
• (message, time_stamp) = receive();
• time = max(time_stamp, time)+1;
• A vector clock is an algorithm for generating a partial ordering of events in a
distributed system and detecting causality violations. Just as in Lamport
timestamps, interprocess messages contain the state of the sending
VECTOR CLOCK ALGORITHM
• Initially, all vectors [0,0,…,0]
• For event on process i, increment own ci
• Label message sent with local vector
• When process j receives message with vector [d1, d2, …, dn]:
• Set local each local entry k to max(ck, dk)
• Increment value of cj
• Physical Clocks
• Can keep closely synchronized, but never perfect
• Logical Clocks
• Encode causality relationship
• Lamport’s clocks provide only one-way encoding
• Vector clocks provide exact causality information
• Causality – If a b then event a can affect event b
• Concurrency – If neither a b nor b a then one event cannot affect the other
• Partial Ordering – Causal events are sequenced
• Total Ordering – All events are sequenced