Global Time State
Global Time State
● One Version
● One daemon without UTC
● Periodically, this daemon polls and asks all the machines for
their time
● The machines respond.
● The daemon computes an average time and then broadcasts
this average time.
● Another Version
● Master/daemon uses Cristian’s algorithm to calculate time from
multiple sources, removes outliers, computes average and
broadcasts
Decentralized Averaging
Algorithm
● Global timestamps:
● (Ta, Pa) where Ta is the local timestamp and
Pa is the process id.
● (Ta,Pa) < (Tb,Pb) iff
● (Ta < Tb) or ( (Ta = Tb) and (Pa < Pb))
● Total order is consistent with partial order.
Properties of Scalar Clocks
● Event counting
● If the increment value d is always 1, the scalar time
has the following interesting property: if event e has
a timestamp h, then h-1 represents the minimum
logical duration, counted in units of events, required
before producing the event e;
● We call it the height of the event e.
● In other words, h-1 events have been produced
sequentially before the event e regardless of the
processes that produced these events.
Properties of Scalar Clocks
● No Strong Consistency
● The system of scalar clocks is not strongly
consistent; that is, for two events ei and ej ,
C(ei ) < C(ej ) does not imply ei → ej .
● Reason: In scalar clocks, logical local clock and
logical global clock of a process are squashed
into one, resulting in the loss of causal
dependency information among events at
different processes.
Independence
● Logical Clocks
● C.adjust(L,T)
● adjust the local time displayed by clock C to T (can be
gradually, immediate, per clock sync period)
● C.read
● returns the current value of clock C
● Timers
● TP.set(T) - reset the timer to timeout in T units
● Messages
● receive(m,l); broadcast(m); forward(m,l)
Simulate A Global State
Time
e11 e12 e13
P1
Time
e11 e12 e13
P1
Time
e11 e12
P1
e21 e22
P2
P3
e31
P4
e41 e42
cut
Poset Diagram
e32
e23
e22
Poset Diagram
e22
e12
e21 e42
e31
Past
e41
e21
Consistent Cuts
Instant of local
observation
Time
P1
5 8
3
initial
value P2
5 2 3 7
4
1
P3
5 4 0
ideal consistent inconsistent
(vertical) cut cut
cut
● Some Theorems
● For a consistent cut consisting of cut events ci,…,cn, no
pair of cut events is causally related. i.e ∀ci,cj ~(ci< cj)
∧ ~(cj< ci)
● The system consists of a collection of n processes p1, p2, ..., pn that are
connected by channels.
● There is no globally shared memory and physical global clock and processes
communicate by passing messages through communication channels.
● No failures in the system.
● Messages are not lost, duplicated or altered.
● Cij denotes the channel from process pi to process pj and its state is denoted
by SCij .
● The actions performed by a process are modeled as three types of events:
● Internal events,the message send event and the message receive event.
● For a message mij that is sent by process pi to process pj , let send(mij)
and rec(mij ) denote its send and receive events.
Process States and Messages
in transit
Initiator Process
Records its process state
Creates a special “marker” message
Sends a “marker” message to all outgoing processes
Turns on recording of messages arriving over all incoming
channels
Chandy-Lamport Distributed
Snapshot Algorithm