Clo cks 1 Goals of the lecture Logical Clo cks (Lamp o - - PowerPoint PPT Presentation

clo cks 1 goals of the lecture logical clo cks lamp o rt
SMART_READER_LITE
LIVE PREVIEW

Clo cks 1 Goals of the lecture Logical Clo cks (Lamp o - - PowerPoint PPT Presentation

Clo cks 1 Goals of the lecture Logical Clo cks (Lamp o rt's clo cks) Concurrency vs Simultaneit y T otal Ordering Physical Clo cks V ecto r Clo cks Vija c y K. Ga rg Distributed


slide-1
SLIDE 1 Clo cks 1 Goals
  • f
the lecture
  • Logical
Clo cks (Lamp
  • rt's
clo cks)
  • Concurrency
vs Simultaneit y
  • T
  • tal
Ordering
  • Physical
Clo cks
  • V
ecto r Clo cks c Vija y K. Ga rg Distributed Systems F all 94
slide-2
SLIDE 2 Clo cks 2 Logical Clo cks A glob al clo ck C : S ! N that satises: 8s; t 2 S : s
  • 1
t _ s ; t ) C (s) < C (t) C : the set
  • f
all global clo cks Equivalent to : 8s; t 2 S : s ! t ) 8C 2 C : C (s) < C (t) (CC)
  • Lemma:
C is non-empt y i (S; !) is an irreexive pa rtial
  • rder.
  • happ
ened-b efo re relation c Vija y K. Ga rg Distributed Systems F all 94
slide-3
SLIDE 3 Clo cks 3 Concurrency
  • simul
taneit y fo r some
  • bserver
8u; v 2 S : ujjv ) 9C 2 C : (C (u) = C (v )) If t w
  • lo
cal states a re concurrent, ) there exists a global clo ck such that b
  • th
states a re assigned the same timestamp. This will sho w the converse
  • f
(CC), i.e., 8s; t 2 S : s 6! t ) 9C 2 C : :(C (s) < C (t)) 3 7 9 12 2 10 13 15 m m u m m
  • m
m m v m
  • 3
7 10 13 2 10 13 16 m m u m m
  • m
m m v m
  • T
ransitivit y ? c Vija y K. Ga rg Distributed Systems F all 94
slide-4
SLIDE 4 Clo cks 4 Logical Clo ck
  • Useful
fo r va rious algo rithms
  • Actions
tak en fo r each event t yp e: F
  • r
any initial state s: s:c = 0; Rule fo r a send event (s; snd; t): /* s.c is sent as pa rt
  • f
msg */ t:c := s:c + 1; Rule fo r a receive event (s; r cv (u); t): t:c := max (s:c; u:c) + 1; Rule fo r an internal event (s; int; t): t:c := s:c + 1; The follo wing claim is easy to verify: (Converse ?) 8s; t 2 S : s ! t ) s:c < t:c c Vija y K. Ga rg Distributed Systems F all 94
slide-5
SLIDE 5 Clo cks 5 Ordering the events totally
  • Extend
the logical clo ck with p ro cess numb er
  • the
timestamp
  • f
any event is a tuple < e:c; e:p >
  • the
total
  • rder
< is
  • btained
as: (e:c; e:p) < (f :c; f :p) , (e:c < f :c) _ ((e:c = f :c) ^ (e:p < f :p)): c Vija y K. Ga rg Distributed Systems F all 94
slide-6
SLIDE 6 Clo cks 6 Physical Clo cks
  • What
if some messages do not follo w the algo rithm ?
  • Given
app ro ximately co rrect physical clo cks,
  • ne
can syn- chronize clo cks such that u ! v implies C (u) < C (v ).
  • =
upp er b
  • und
  • n
the drift rate
  • f
any clo ck
  • =
minimum transmission time fo r any message
  • t
= physical time at which the message is sent W e require C i (t + ) > C j (t) fo r all i; j; t: F rom the b
  • und
  • n
the drift w e kno w that C i (t + ) > C i (t) + (1
  • ):
Thus, w e need C i (t) + (1
  • )
> C j (t). That is, C j (t)
  • C
i (t) < (1
  • ).
c Vija y K. Ga rg Distributed Systems F all 94
slide-7
SLIDE 7 Clo cks 7 Clo ck Synchronization Algo rithm The synchronization constant () < (1
  • ).
  • Algo
rithm:
  • send
  • ut
a timestamp ed message along its
  • utgoing
link at least every
  • seconds.
  • Every
message tak es time b et w een
  • and
  • +
  • .
  • On
receipt
  • f
a message timestamp e d with T m , the clo ck is up dated as maximum
  • f
the p revious value and T m + .
  • Let
the net w
  • rk
b e strongly connected with d as the diam- eter. Then, it can b e sho wn that
  • =
d(2 +
  • )
fo r all t > t +
  • d
assuming that
  • +
  • <<
  • .
h h h h h h h h
  • A
A A A A A U
  • @
@ @ R 6 @ @ @ I
  • 6
  • c
Vija y K. Ga rg Distributed Systems F all 94
slide-8
SLIDE 8 Clo cks 8 V ecto r Clo cks
  • Logical
clo cks satisfy s ! t ) s:c < t:c: Ho w ever, the converse is not true.
  • V
ecto r clo ck satisfy: s ! t , s:v < t:v : c Vija y K. Ga rg Distributed Systems F all 94
slide-9
SLIDE 9 Clo cks 9 Consistent Cuts
  • (E
; )
  • do
wn-set Y in this pa rtial
  • rder
will b e called a p rex.
  • The
set
  • f
all p rexes is a lattice.
  • supY
fo r any p rex Y is called a cut.
  • (E
; !) where ! is the causal-p recedes.
  • A
do wn-set Y in this pa rtial
  • rder
is called a consistent p rex.
  • Simila
rly , sup Y is called a consistent cut.
  • The
set
  • f
all consistent p rexes is also a lattice. F
  • E
is a consistent cut i 8e; f 2 F : :(e ! f ).
  • H
H H H H H j H H H H H H j
  • 1
  • *
Cut A Cut B c Vija y K. Ga rg Distributed Systems F all 94
slide-10
SLIDE 10 Clo cks 10 V ecto r Algo rithm
  • Let
there b e N p ro cesses
  • Algo
rithm: F
  • r
any initial state s: (8i : i 6= s:p : s:v [i] = 0) ^ (s:v [s:p] = 1) Rule fo r an internal event (s; int; t): t:v := s:v ; t:v [t:p] + +; s B B B @ 1 1 C C C A s B B B @ 1 1 1 C C C A s B B B @ 1 1 1 C C C A s B B B @ 2 1 C C C A s B B B @ 2 1 1 C C C A s B B B @ 2 1 2 1 1 C C C A s B B B @ 2 1 C C C A s B B B @ 2 1 3 1 1 C C C A s B B B @ 2 3 3 1 1 C C C A s B B B @ 1 1 C C C A
  • A
A A A A A A A A A A A U
  • P
1 P 2 P 3 P 4 c Vija y K. Ga rg Distributed Systems F all 94
slide-11
SLIDE 11 Clo cks 11 V ecto r Algo rithm [Contd.] Rule fo r a send event (s; snd; t): t:v := s:v ; t:v [t:p] + +; Rule fo r a receive event (s; r cv (u); t): fo r i := 1 to N t:v [i] := max (s:v [i]; u:v [i]); t:v [t:p] + +; s B B B @ 1 1 C C C A s B B B @ 1 1 1 C C C A s B B B @ 1 1 1 C C C A s B B B @ 2 1 C C C A s B B B @ 2 1 1 C C C A s B B B @ 2 1 2 1 1 C C C A s B B B @ 2 1 C C C A s B B B @ 2 1 3 1 1 C C C A s B B B @ 2 3 3 1 1 C C C A s B B B @ 1 1 C C C A
  • A
A A A A A A A A A A A U
  • P
1 P 2 P 3 P 4 c Vija y K. Ga rg Distributed Systems F all 94
slide-12
SLIDE 12 Clo cks 12 Prop erties
  • f
the V ecto r Clo ck Algo rithm Lemma 1 L et s 6= t. Then, s 6! t ) t:v [s:p] < s:v [s:p] Pro
  • f:
  • t:p
= s:p: then it follo ws that t
  • s.
  • s:p
6= t:p. Since s:v [s:p] is the lo cal clo ck
  • f
P s:p and P t:p could not have seen this value as s 6! t Theorem 1 s ! t i s:v < t:v . Pro
  • f:
(s ! t) ) (s:v < t:v )
  • s
! t: there is a message path from s to t. Therefo re, 8k : s:v [k ]
  • t:v
[k ]. F urthermo re, since t 6! s, from lemma 1 t:v [j ] > s:v [j ].
  • The
converse follo ws from Lemma 1. c Vija y K. Ga rg Distributed Systems F all 94
slide-13
SLIDE 13 Clo cks 13 Optimizatio n Recall x < y if and
  • nly
if (8i : x[i]
  • y
[i]) ^ (9j : x[j ] < y [j ]). If w e kno w the p ro cesses the vecto rs came from, the compa rison b et w een t w
  • states
can b e made in constant time. Lemma 2 s ! t i (s:v [s:p]
  • t:v
[s:p]) ^ (s:v [t:p] < t:v [t:p]) s B B B @ 1 1 C C C A s B B B @ 1 1 1 C C C A s B B B @ 1 1 1 C C C A s B B B @ 2 1 C C C A s B B B @ 2 1 1 C C C A s B B B @ 2 1 2 1 1 C C C A s B B B @ 2 1 C C C A s B B B @ 2 1 3 1 1 C C C A s B B B @ 2 3 3 1 1 C C C A s B B B @ 1 1 C C C A
  • A
A A A A A A A A A A A U
  • P
1 P 2 P 3 P 4 c Vija y K. Ga rg Distributed Systems F all 94