01-01-2013, 12:21 PM
Simulate the functioning of Vector Clock in C
Simulate the functioning of Vector Clock in C.docx (Size: 12.48 KB / Downloads: 59)
VECTOR CLOCK
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 process's logical clock.
Example of a system of vector clocks
A vector clock of a system of N processes is an array of N logical clocks, one per process, a local copy of which is kept in each process with the following rules for clock updates:
Initially all clocks are zero.
Each time a process experiences an internal event, it increments its own logical clock in the vector by one.
Each time a process prepares to send a message, it increments its own logical clock in the vector by one and then sends its entire vector along with the message being sent.
Each time a process receives a message, it increments its own logical clock in the vector by one and updates each element in its vector by taking the maximum of the value in its own vector clock and the value in the vector in the received message (for every element).
The vector clocks algorithm was independently developed by Colin Fidge and Friedemann Mattern in 1988.