Hawker
Hawker

Reputation: 1

About distributed logical clock, Lamport Algorithm

Hi everyone I would like to ask about the logical clock in distrbuted system. Lamport algorithms defines that when events a in process Pi send a message, and in Process Pj events b received that message, then it could be defined that events a is happened before b. Suppose before Process Pj received the message at events b, events c happened on Pj (thus c is happened before b) and send a message Process Pi, and then Process Pi received the message at events d after event a, then we have event c, as well as a, happened before d.

My question is, how to define the relationship between event a (The first event happened on Process Pi)and event c(The first event happened on Process Pj)? How to let process Pi and Pj both agree on the order of event a and c?

Lamport Algorithm: http://en.wikipedia.org/wiki/Lamport_timestamps

Upvotes: 0

Views: 2738

Answers (2)

The important thing is that the processes coincide in the order that the events happen. To synchronize logical clocks, Lamport defined a relationship called a prior occurrence. The expression a -> b is read as "a occurs before b". This relationship of occurrence can be seen in 2 situations:

  1. If 'a' and 'b' are events of the same process, and 'a' occurs before 'b', then a -> b is true.

  2. If 'a' is the event in which a process sends a message, and 'b' is the event of receipt of the message by another process, then a-> b is also true.

How does the algorithm work?

Each message has the sender's sending time. So the receiver modifies the time, in case its time is less than the time of the transmitter. So the Algorithm syncronizes the receiver's clock. Each message that is sent to another process will contain the unit of time in which the message was sent, and thus the clocks are checked.

Upvotes: 0

TonySalimi
TonySalimi

Reputation: 8437

The answer is simple. Based on the Lamport algorithm, you cannot define any relationships between events a and c. All the things we know are:

a -> b and c -> d and a -> d and c -> b

but you cannot conclude either a -> c or c -> a that's all.

Upvotes: 3

Related Questions