Vector clock

From Wikipedia, the free encyclopedia

Vector Clocks is an algorithm for generating a partial ordering of events in a distributed system. Just as in Lamport timestamps, interprocess messages contain the state of the sending process's logical clock. 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:

Example of a system of vector clocks
Example of a system of vector clocks
  • 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 developed by F. Mattern in 1989.[1]

[edit] Partial ordering property

Vector clocks allow for the partial causal ordering of events. because of an equivalence relation between the vector clock at a particular event and the physical time of the event. Specifically:

  • For any two events a and b, if VC(a) < VC(b), then time(a) < time(b).
  • Symmetrically: if time(a) < time(b), then VC(a) < VC(b)
  • Antisymmetry: if VC(a) < VC(b), then ¬ VC(b) < VC(a)
  • Transitivity: if VC(a) < VC(b) or time(a) < time(b) and VC(b) < VC(c) or time(b) < time(c), then VC(a) < VC(c)

Where:

  • VC(x) denote the vector clock of event x
  • time(x) denote the physical time occurrence
  • VC(x) < VC(y) \iff \forall z [VC(x)_z \le VC(y)_z] \and \exists z' [ VC(x)_{z'} < VC(y)_{z'} ]
    • In English: VC(x) is less than VC(y) if and only if VC(x)[z] is less than or equal to VC(y)[z] for all indices z and there exists an index z' such that VC(x)[z'] is strictly less than VC(y)[z'].

[edit] See also

[edit] References

  1. ^ Mattern, F. (Oct. 1988), “Virtual Time and Global States of Distributed Systems”, in Cosnard, M., Proc. Workshop on Parallel and Distributed Algorithms, Chateau de Bonas, France: Elsevier, pp. 215-226 
Languages