SES Algorithm
SES Algorithm
SES: Schiper-Eggli-Sandoz Algorithm. No need for broadcast messages. Each process maintains a vector V_P of size N - 1, N the number of processes in the system. V_P is a vector of tuple (P,t): P the destination process id and t, a vector timestamp. Tm: logical time of sending message m Tpi: present logical time at pi Initially, V_P is empty.
SES Algorithm
Sending a Message:
Send message M, time stamped tm, along with V_P1 to P2. Insert (P2, tm) into V_P1. Overwrite the previous value of (P2,t), if any. (P2,tm) is not sent. Any future message carrying (P2,tm) in V_P1 cannot be delivered to P2 until tm < tP2. If V_M (in the message) does not contain any pair (P2, t), it can be delivered. /* (P2, t) exists */ If t Tp2, buffer the message. (Dont deliver). else (t < Tp2) deliver it
Delivering a message
When t < Tp2, message is delivered & Tp2 is updated with the help of V_P2 (after the merge operation).
(2,2,2)
V_P2: (P1, <0,1,0>) (P3, <0,2,0>)
Tp2: P2 (0,1,0) (0,2,0) M1 M2 V_P2 V_P2: empty (P1, <0,1,0>) P3 Tp3: (0,2,1)
V_P3: M4 (P1,<0,2,2>)
Message cannot be delivered until t in V_M is greater than t in V_P2 Update site P2s local, logical clock. Check buffered messages after local, logical clock update.
SES Algorithm
P1
(1,2,1) (2,2,1)
P2
(0,1,1) M2
Global State
Global State 1 C1: Empty $500 A C2: Empty $200 B
Global State 2
C1: Tx $50
$200
B
$450
A C2: Empty
$250
B
Also, n >= m, as in no system no. of messages sent along the channel be less than that received Hence, n >= m Consistent global state should satisfy the above equation. Consistent global state:
Channel state: sequence of messages sent before recording senders state, excluding the messages received before receivers state was recorded. 10 Only transit messages are recorded in the channel state.
11
12
LS1 M2
13
LS23
LS31
LS32
LS33
14
Chandy-Lamport Algorithm
Distributed algorithm to capture a consistent global state. Communication channels assumed to be FIFO. Uses a marker to initiate the algorithm. Marker sort of dummy message, with no effect on the functions of processes. Sending Marker by P: P records its state. For each outgoing channel C, P sends a marker on C before P sends further messages along C. Receiving Marker by Q: If Q has NOT recorded its state: (a). Record the state of C as an empty sequence. (b) SEND marker (use above rule). Else (Q has recorded state before): Record the state of C as sequence of messages received along C, after Qs state was recorded and before Q received the marker.
15
Chandy-Lamport Algorithm
Initiation of marker can be done by any process, with its own unique marker: <process id, sequence number>. Several processes can initiate state recording by sending markers. Concurrent sending of markers allowed. One possible way to collect global state: all processes send the recorded state information to the initiator of marker. Initiator process can sum up the global state. Seq Si Sc Seq Sj
16
Send Send Marker Record Marker Record channel channel state state
17
Pj
18
Cuts
Cuts: graphical representation of a global state. Cut C = {c1, c2, .., cn}; ci: cut event at Si. Consistent Cut: If every message received by a Si before a cut event, was sent before the cut event at Sender. One can prove: A cut is a consistent cut iff no two cut events are causally related, i.e., !(ci -> cj) and !(cj -> ci). VTc=<3,8 ,6,4> c1 <3,2,5,4>
S1 S2 S3 S4 c4 c2<2,7,6,3> c3 <2,8,5,4>
19
Time of a Cut
C = {c1, c2, .., cn} with vector time stamp VTci. Vector time of the cut, VTc = sup(VTc1, VTc2, .., VTcn). sup is a component-wise maximum, i.e., VTci = max(VTc1[i], VTc2[i], .., VTcn[i]). Now, a cut is consistent iff VTc = (VTc1[1], VTc2[2], .., VTcn[n]).
20
Termination Detection
Termination: completion of the sequence of algorithm. (e.g.,) leader election, deadlock detection, deadlock resolution. Use a controlling agent or a monitor process. Initially, all processes are idle. Weight of controlling agent is 1 (0 for others). Start of computation: message from controller to a process. Weight: split into half (0.5 each). Repeat this: any time a process send a computation message to another process, split the weights between the two processes (e.g., 0.25 each for the third time). End of computation: process sends its weight to the controller. Add this weight to that of controllers. (Sending processs weight becomes 0). Rule: Sum of W always 1. Termination: When weight of controller becomes 1 again.
21
Huangs Algorithm
B(DW): computation message, DW is the weight. C(DW): control/end of computation message; Rule 1: Before sending B, compute W1, W2 (such that W1 + W2 is W of the process). Send B(W2) to Pi, W = W1. Rule 2: Receiving B(DW) -> W = W + DW, process becomes active. Rule 3: Active to Idle -> send C(DW), W = 0. Rule 4: Receiving C(DW) by controlling agent -> W = W + DW, If W == 1, computation has terminated.
22
Huangs Algorithm
1/4 P1
0.5
P1
1/2
P2
P3 1/16
0.5
P2
P3 0
P4 1/8
P5
1/16
0 P4
0 P5
23