Event Ordering
Three types of events:
- Local computation
- Sending a message
- Receiving a message
Happened-Before Relationship
- e → e’ means e happened before e’.
- e →ie′ means e happened before e′ , as observed by Pi
HB rules:
- If ∃Pi,e→ie′ then e→e′ .
- For any message m , send (m)→ receive (m)
- If e→e′ and e′→e′′ then e→e′′
This is also called “causal” or “potentially causal” ordering.
{: .prompt-info }
if a↛e and e↛a then a∥e , i.e. a and e are concurrent.
Lamport’s Logical Clock
Algorithm: for each process Pi :
- init local lock Li=0
- Li+=1 before timestamping each event
- for each message m to send, send (m,Li)
- upon receiving (m,t)
- Li=max(t,Li)
- Do step (2)
if events e→e′ , then L(e)<L(e’)
Vector Clocks
Vi[j] is the clock for process Pj as maintained by Pi
Algorithm: for each process Pi :
- initializes local clock Vi[⋅]=0
- Vi[i]+=1 before timestamping each event.
- for each message m to send, send (m,Vi)
- upon receiving (m,v)
- ∀j:Vi[j]=max(Vi[j],v[j])
- Do step (2)
Comparing Vector Timestamps
- Let V(e)=V and V(e′)=V′
- V=V′ , iff V[i]=V′[i] , for all i=1,…,n
- V≤V ', iff V[i]≤V′[i] , for all i=1,…,n
- V<V′ , iff V≤V′ and V=V′
- e →e′ iff V<V′
- e ∥e′ iff (V≮V′ and V′≮V)
Global State (or Global Snapshot)
State of each process (and each channel) in the system at a
given instant of time.
definitions
For a process Pi ,
where events ei0,ei1,… occur:
- history (Pi)=hi=<ei0,ei1,…>
- prefix history (Pik)=hik=<ei0,ei1,…,eik>
- sik : Pi 's state immediately after k-th event.
For a set of process <P1,P2,…,Pn> ,
- global history: H=∪i(hi)
- global state: S=∪i(si)
- a cut C⊆H=h1c1∪h2c2∪…∪hncn
- the frontier of C={eici,i=1,2,…n}
Consistent cut
A cut C is consistent iff
$ ∀e∈C,if f→e then f∈C $