Professional Documents
Culture Documents
DC Experiment No 4
DC Experiment No 4
DIV:B Batch:C
ID:vu1f2021100
Distributed Computing
Experiment No. 4
Theory:
Vector timestamps provide a more refined approach to capturing causal relationships among
events in distributed systems compared to Lamport's Logical Clocks. Here's a deeper dive
into the theory behind Vector Timestamps:
The process increments its own logical clock to reflect the occurrence of the event.
When a process sends a message, it includes its current vector timestamp in the message.
Upon receiving a message, the recipient process updates its vector timestamp. For each
element in the vector, the recipient takes the maximum of its current value and the
corresponding value from the received timestamp.
After updating the vector timestamp, the logical clock of the recipient process is incremented.
Two events are considered concurrent if neither causally precedes the other.
Vector timestamps respect the happens-before relationship more accurately than Lamport's
Logical Clocks. They provide a partial ordering of events that reflects the causal
dependencies in a distributed system.
Vector timestamps can be used to implement causal consistency and other consistency models
in distributed databases.
CODE:
import java.util.Arrays;
class VectorTimestamp {
private int[] timestamp;