Vector clock
From Wikipedia, the free encyclopedia
(Redirected from Vector clocks)
Vector clocks 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. 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. [1] [2]
Contents |
[edit] Partial ordering property
Vector clocks allow for the partial causal ordering of events. Defining the following:
- VC(x) denote the vector clock of event x
- 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'].
denote event x happened before event y. It's defined as: if
, then VC(x) < VC(y)
Properties:
- If VC(a) < VC(b), then

- Antisymmetry: if VC(a) < VC(b), then ¬ VC(b) < VC(a)
- Transitivity: if VC(a) < VC(b) and VC(b) < VC(c), then VC(a) < VC(c) or if
and
, then 
Relation with other orders:
- Let RT(x) be the real time when event x occurs. If VC(a) < VC(b), then RT(a) < RT(b)
- Let C(x) be the lamport timestamp of event x. If VC(a) < VC(b), then C(a) < C(b)
[edit] Other Mechanisms
- Torres-Rojas and Ahamad, developed in 1999 Plausible Clocks[3], a mechanism that takes less space than vector clocks but that, in some cases, will totally order events that are causally concurrent.
- Almeida et al, introduced in 2008 Interval Tree Clocks[4]. This mechanism generalizes Vector Clocks and allows operation in dynamic environments when the identities and number of processes in the computation is not known in advance.
[edit] See also
[edit] References
- ^ Colin J. Fidge (February 1988). "Timestamps in message-passing systems that preserve the partial ordering". in K. Raymond (Ed.). Proc. of the 11th Australian Computer Science Conference (ACSC'88). pp. 56–66. http://sky.scitech.qut.edu.au/~fidgec/Publications/fidge88a.pdf. Retrieved 2009-02-13.
- ^ Mattern, F. (October 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
- ^ Torres-Rojas, Francisco; Ahamad, Mustaque (1999), "Plausible clocks: constant size logical clocks for distributed systems", Distributed Computing (Springer Verlag) 12 (4): 179–195
- ^ Almeida, Paulo; Baquero, Carlos; Fonte, Victor (2008), "Interval Tree Clocks: A Logical Clock for Dynamic Systems", Principles of Distributed Systems, 5401, Springer-Verlag, Lecture Notes in Computer Science, pp. 259–274, doi:, http://gsd.di.uminho.pt/members/cbm/ps/itc2008.pdf