Clo cks [Contd.] 1 Goals of the lecture � Direct dep endency clo cks � Pred and Succ functions � Matrix clo cks � Prop erties of matrix clo cks � Vija c y K. Ga rg Distributed Systems Sp ring 96
Clo cks [Contd.] 2 Overhead of the vecto r clo ck algo rithm m = # of messages sent/recd b y any p ro cess n = # of p ro cesses � Space overhead : n log m � Time overhead : O ( n ) � Communication overhead : n log m � Vija c y K. Ga rg Distributed Systems Sp ring 96
Clo cks [Contd.] 3 Direct Dep endency Clo cks � Main dra wback of the vecto r clo ck algo rithm � O ( N ) integers with every message � Direct Dep endency Clo cks require only one integer to b e app ended to each message � Used in Lamp o rt's algo rithm fo r mutual exclusion � Vija c y K. Ga rg Distributed Systems Sp ring 96
Clo cks [Contd.] 4 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 a send event ( s; snd; t ) o r an internal ( s; int; t ) : t:v [ t:p ] := s:v [ t:p ] + 1; Rule fo r a receive event ( s; r cv ( u ) ; t ) : t:v [ t:p ] := max( s:v [ t:p ] ; u:v [ u:p ]) + 1; t:v [ u:p ] := max ( u:v [ u:p ] ; s:v [ u:p ]) ; 1 - 0 @ @ 0 1 @ @ 1 @ @ R - 0 @ 1 @ 0 @ 2 2 @ 1 0 @ @ R - 0 0 0 2 3 � Vija c y K. Ga rg Distributed Systems Sp ring 96
Clo cks [Contd.] 5 Prop erties of Direct Dep endency Clo cks � p rojection on i th comp onent results in the logical clo ck algo rithm. Lemma 1 s ! t ) s:v [ s:p ] < t:v [ t:p ] Converse ? Lemma 2 ( 8 s; t :: s 6! t ) : ( s:v [ s:p ] � t:v [ s:p ]) Converse ? � Vija c y K. Ga rg Distributed Systems Sp ring 96
; Clo cks [Contd.] 6 Direct Dep endency s ! t � ( s � t ) _ ( 9 q ; r : s � q ^ q r ^ r � t ) d s s - @ @ @ @ t R @ s - Lemma 3 8 s; t : s:p 6 = t:p : : ( s ! t ) ) : ( s:v [ s:p ] � d t:v [ s:p ]) ! ! d � Vija c y K. Ga rg Distributed Systems Sp ring 96
Clo cks [Contd.] 7 Higher Dimensional Clo cks W e describ e a matrix clo ck and its p rop erties b elo w. T o initialize: M [ � ; � ] := 0; k M [ k ; k ] := M [ k ; k ] + 1; k k T o send a message: T ag message with M [ � ; � ]; k M [ k ; k ] := M [ k ; k ] + 1; incr ement lo c al clo ck k k Up on receipt of a message tagged with W [ � ; � ] : for i := 1 to n do if ( M [ i; i ] < W [ i; i ]) then k M [ i; � ] := W [ i; � ]; c opy ve ctor clo ck for ( i; W [ i; i ]) k M [ k ; k ] := M [ k ; k ] + 1; incr ement lo c al clo ck k k M [ k ; � ] := diag onal ( M ); k k � Vija c y K. Ga rg Distributed Systems Sp ring 96
Clo cks [Contd.] 8 � Vija c y K. Ga rg Distributed Systems Sp ring 96
Clo cks [Contd.] 9 Interval � e f g h � t t t t - @ R @ e � f i� there is no communication b et w een the state e and f . � is an equivalence relation. F urther, � is a congruence w.r.t. ! . That is, 0 0 0 s � s ) 8 u : u:p 6 = s:p : ( s ! u � s ! u ) ^ ( u ! s � u ! s ) Congruence exploited b y assigning same identi�er to all states in the same equivalence class (interval). � Vija c y K. Ga rg Distributed Systems Sp ring 96
Clo cks [Contd.] 10 Interval [contd.] (1,1) (1,2) (1,3) (1,4) - @ A � � @ A � @ A � @ A � @ A � @ A (2,1) (2,2) � @ A R @ - � A � A � A � A � A � A � (3,1) (3,2) (3,3) A U A � - � Vija c y K. Ga rg Distributed Systems Sp ring 96
Clo cks [Contd.] 11 Pred and Succ functions � S = set of lo cal states at P i i � Defn of Pred : pr ed:u:i = max f v j v 2 S ^ v ! u g i returns ? if the ab ove set is empt y . Simila r defn fo r Succ Because of congruence, can use intervals instead of states. Lemma 4 ( p; i ) = pr ed: ( q ; j ) :p ) ( 8 k : k > i : ( p; k ) 6! ( q ; j )) � Vija c y K. Ga rg Distributed Systems Sp ring 96
Clo cks [Contd.] 12 F o r V ecto r Clo cks n V = vecto r clo ck in the interval ( k ; n ) k n 8 i; k ; n : k 6 = i : pr ed: ( k ; n ) :i = V [ i ] k (1 ; 1) (1 ; 2) - @ [1 ; 0 ; 0] [2 ; 0 ; 0] @ @ @ @ (2 ; 1) [1 ; 2 ; 0] [1 ; 3 ; 0] @ R - @ [0 ; 1 ; 0] (2 ; 2) (2 ; 3) @ @ @ @ (3 ; 1) (3 ; 2) R @ - [0 ; 0 ; 1] [1 ; 2 ; 2] � Vija c y K. Ga rg Distributed Systems Sp ring 96
Clo cks [Contd.] 13 Prop erties of Matrix Clo ck th � F o r P ; i ro w implements the vecto r clo ck i n � M [ k ; k ] = n k th � Diagonal is same as the i ro w � Vija c y K. Ga rg Distributed Systems Sp ring 96
Clo cks [Contd.] 14 Prop erties of Matrix Clo ck [Contd.] n n � i 6 = j ) ( j; M [ i; j ]) = pr ed: ( i; M [ i; i ]) :j k k n � i 6 = j ) pr ed: ( pr ed: ( k ; n ) :i ) :j = ( j; M [ i; j ]) k n pr ed: ( k ; n ) :i = M [ k ; i ] k h - P i ( k ; n ) h - P k - h - P j pr ed: ( pr ed: ( k ; n ) :i ) :j � Vija c y K. Ga rg Distributed Systems Sp ring 96
Clo cks [Contd.] 15 Disca rding Obsolete Info rmation If p ro cess s:p �nds that its s:p column is unifo rmly bigger than r :v [ s:p; s:p ] (that is, its lo cal clo ck in some p revious state r ), then the info rmation at r has b een received b y all p ro cesses. Lemma 5 L et s:p = r :p . If ( 8 i : s:v [ i; s:p ] � r :v [ r :p; r :p ]) , then 8 t : t k s : r ! t . � - Pro of : t - P i � @ � @ � @ � @ r s s � R @ s - P s:p @ � @ � @ � @ � @ R � - t k s ) pr ed ( s ) :i ! t (1) ( 8 i : s:v [ i; s:p ] � r :v [ r :p; r :p ]) ) r � pr ed: ( pr ed ( s ) :i ) : ( s:p ) (2) F rom the ab ove t w o equations: r ! t . � Vija c y K. Ga rg Distributed Systems Sp ring 96
Recommend
More recommend