Lamport Clocks
Let's examine what Lamport clocks are and how they work.
We'll cover the following
Leslie Lamport invented one of the first and simplest types of logical clocks, called the
In this type of logical clock, every node in the system maintains a logical clock in the form of a numeric counter that starts from zero when a node starts operating.
Rules of the protocol
- (R1) Before executing an event (send, receive, or local), a node increments the counter of its logical clock by one: .
- (R2) Every sent message piggybacks the clock value of its sender at sending time. When a node receives a message with timestamp , it executes the following actions:
- Updates its clock by taking the maximum of its clock and the received clock:
- Executes R1
- Delivers the message
Get hands-on with 1200+ tech skills courses.