clo cks 1 goals of the lecture logical clo cks lamp o rt
play

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


  1. 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 Systems F all 94

  2. Clo cks 2 Logical Clo cks A glob al clo ck C : S ! N that satis�es: 8 s; t 2 S : s � t _ s ; t ) C ( s ) < C ( t ) 1 C : the set of all global clo cks Equivalent to : 8 s; t 2 S : s ! t ) 8 C 2 C : C ( s ) < C ( t ) ( CC ) � Lemma: C is non-empt y i� ( S; ! ) is an irre�exive pa rtial o rder. � happ ened-b efo re relation c � Vija y K. Ga rg Distributed Systems F all 94

  3. Clo cks 3 Concurrency � simul taneit y fo r some observer 8 u; v 2 S : u jj v ) 9 C 2 C : ( C ( u ) = C ( v )) If t w o lo cal states a re concurrent, ) there exists a global clo ck such that b oth states a re assigned the same timestamp. This will sho w the converse of (CC), i.e., 8 s; t 2 S : s 6! t ) 9 C 2 C : : ( C ( s ) < C ( t )) 3 7 9 12 3 7 10 13 m - m - m - m m - m - m - m u u � � � � � � � � � � � � � � � � � � � � m � - m - m � - m m � - m - m � � - m v v 2 10 13 15 2 10 13 16 T ransitivit y ? c � Vija y K. Ga rg Distributed Systems F all 94

  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 o r any initial state s : s:c = 0; Rule fo r a send event ( s; snd; t ) : /* s.c is sent as pa rt of 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 ?) 8 s; t 2 S : s ! t ) s:c < t:c c � Vija y K. Ga rg Distributed Systems F all 94

  5. Clo cks 5 Ordering the events totally � Extend the logical clo ck with p ro cess numb er � the timestamp of any event is a tuple < e:c; e:p > � the total o rder < is obtained 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

  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, one can syn- chronize clo cks such that u ! v implies C ( u ) < C ( v ) . � � = upp er b ound on the drift rate of any clo ck � � = minimum transmission time fo r any message � t = physical time at which the message is sent W e require C ( t + � ) > C ( t ) fo r all i; j; t: i j F rom the b ound on the drift w e kno w that C ( t + � ) > C ( t ) + (1 � � ) �: i i Thus, w e need C ( t ) + (1 � � ) � > C ( t ) . i j That is, C ( t ) � C ( t ) < (1 � � ) � . j i c � Vija y K. Ga rg Distributed Systems F all 94

  7. Clo cks 7 Clo ck Synchronization Algo rithm The synchronization constant ( � ) < (1 � � ) � . � Algo rithm: � send out a timestamp ed message along its outgoing link at least every � seconds. � Every message tak es time b et w een � and � + � . � On receipt of a message timestamp e d with T , the clo ck is up dated m as maximum of the p revious value and T + � . m � Let the net w o 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 � + � << � . 0 h h � 6 @ � � � A @ � R @ � A h h � A I @ � � � A @ � � � A U A - h h @ � � h � 6 � � � � � h � Vija c y K. Ga rg Distributed Systems F all 94

  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 : � Vija c y K. Ga rg Distributed Systems F all 94

  9. Clo cks 9 Consistent Cuts � ( E ; � ) � do wn-set Y in this pa rtial o rder will b e called a p re�x. � The set of all p re�xes is a lattice. � sup Y fo r any p re�x Y is called a cut . � ( E ; ! ) where ! is the causal-p recedes. � A do wn-set Y in this pa rtial o rder is called a consistent p re�x. � Simila rly , sup Y is called a consistent cut. � The set of all consistent p re�xes is also a lattice. F � E is a consistent cut i� 8 e; f 2 F : : ( e ! f ) . Cut B Cut A - H H H H H H j - 1 � H � � H � H � � H � � H � j H - � * � � � � � - � Vija c y K. Ga rg Distributed Systems F all 94

  10. Clo cks 10 V ecto r Algo rithm � Let there b e N p ro cesses � Algo rithm: F o r any initial state s : ( 8 i : 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 ; s P s - 1 0 1 0 1 A 1 2 � � A t:v [ t:p ] + +; B C B C � 1 1 B C B C A B C B C � A @ 0 A @ 0 A � A 0 0 � A P s s s - 2 0 1 0 1 0 1 A 0 0 � 2 � A B C B C B C � 1 2 3 B C B C B C A B C B C B C � A @ 0 A @ 0 A @ 3 A � A A U 0 0 1 � P s s s - 3 0 1 0 1 0 1 � 0 2 2 � B C B C B C � 0 1 1 B C B C B C B C B C B C � @ A @ A @ A 1 2 3 � � 1 1 1 P s s - 4 0 1 0 1 0 0 B C B C 0 0 B C B C B C B C @ A @ A 0 0 1 2 � Vija c y K. Ga rg Distributed Systems F all 94

  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 P s - 1 0 1 0 1 A 2 � 1 � A B C B C � 1 1 B C B C A B C B C � A @ 0 A @ 0 A � A 0 0 � P s s A s - 2 0 1 0 1 0 1 A 0 0 � 2 � A B C B C B C � 1 2 3 B C B C B C A B C B C B C � A @ A @ 0 A @ 0 A 3 � A U A 0 0 1 � P s s s - 3 1 0 1 0 1 0 � 0 2 2 � B C B C B C � 0 1 1 B C B C B C B C B C B C � @ A @ A @ A 1 2 3 � � 1 1 1 P s s - 4 0 1 0 1 0 0 B C B C 0 0 B C B C B C B C @ 0 A @ 0 A 1 2 c � Vija y K. Ga rg Distributed Systems F all 94

  12. Clo cks 12 Prop erties of 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 of: � 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 of P and P could not s:p t:p have seen this value as s 6! t Theorem 1 s ! t i� s:v < t:v . Pro of : ( s ! t ) ) ( s:v < t:v ) � s ! t : there is a message path from s to t . Therefo re, 8 k : 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. � Vija c y K. Ga rg Distributed Systems F all 94

  13. Clo cks 13 Optimizatio n Recall x < y if and only if ( 8 i : x [ i ] � y [ i ]) ^ ( 9 j : 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 o 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 P s - 1 0 1 0 1 A 2 � 1 � A B C B C � 1 1 B C B C A B C B C � A @ A @ 0 A 0 � A 0 0 � A P s s s - 2 0 1 0 1 0 1 A 0 0 � 2 � A B C B C B C � 1 2 3 B C B C B C A B C B C B C � A @ 0 A @ 0 A @ 3 A � A U A 0 0 1 � P s s s - 3 0 1 0 1 0 1 � 0 2 2 � B C B C B C � 0 1 1 B C B C B C B C B C B C � @ A @ A @ A 1 2 3 � 1 1 1 � P s s - 4 0 1 0 1 0 0 B C B C 0 0 B C B C B C B C @ A @ A 0 0 1 2 � Vija c y K. Ga rg Distributed Systems F all 94

Recommend


More recommend