Distributed and Parallel Systems: M. T. Bennani Assistant Professor, FST - El Manar University, LISI-INSAT
Distributed and Parallel Systems: M. T. Bennani Assistant Professor, FST - El Manar University, LISI-INSAT
M. T. Bennani
Assistant Professor, FST - El Manar University, LISI-INSAT
Challenges
2 / 18
Introduction System model and definitions Snapshot algorithm for FIFO channels Non-FIFO channels
Example
I Two distincts sites of distributed
banking: S1, S2
I Two different accounts: A, B
I C12 : Communication channel from
S1 to S2
I C21 : Communication channel from
S2 to S1
I t0 :A=600, B=200, C12 =0, C21 =0
I t1 :A=550, B=200, C12 =50, C21 =0
I t2 :A=550, B=120, C12 =50, C21 =80
I t3 :A=630, B=120, C12 =50, C21 =0
I t4 :A=630, B=170, C12 =0, C21 =0
If we record the global state of the application using:
I Local state of A at t0
I Local state of B, C12 and C21 at t2
An extra $50 appears in the system
3 / 18
Introduction System model and definitions Snapshot algorithm for FIFO channels Non-FIFO channels
System model
I The system consists of a colection of n processes p1 , .., pn connected
by channels.
I At any instant, the state of process pi , denoted by LSi , is a result
of the sequence of all the events executed by pi till that instant.
I For an event e and a process state LSi , e ∈ LSi iff e belongs to the
sequence of events that have taken process pi to state LSi .
I For an event e and a process state LSi , e ∈
/ LSi iff e does not belong
to the sequence of events that have taken process pi to state LSi .
I For a channel Cij , the following set of messages can be defined
based on the local states of the processes pi and pj
Transit: transit(LSi , LSj ) = {mij / send(mij ) ∈ LSi ∧ rec(mij ) ∈
/ LSj }
Note: The global state isn’t only the union of the local states but also it
should include the channel state.
4 / 18
Introduction System model and definitions Snapshot algorithm for FIFO channels Non-FIFO channels
Communications model
5 / 18
Introduction System model and definitions Snapshot algorithm for FIFO channels Non-FIFO channels
C2 send(mij ) ∈
/ LSi ⇒ mij ∈
/ SCij ∧ rec(mij ) ∈
/ LSj
6 / 18
Introduction System model and definitions Snapshot algorithm for FIFO channels Non-FIFO channels
7 / 18
Introduction System model and definitions Snapshot algorithm for FIFO channels Non-FIFO channels
8 / 18
Introduction System model and definitions Snapshot algorithm for FIFO channels Non-FIFO channels
9 / 18
Introduction System model and definitions Snapshot algorithm for FIFO channels Non-FIFO channels
Chandy-Lamport algorithm
10 / 18
Introduction System model and definitions Snapshot algorithm for FIFO channels Non-FIFO channels
Chandy-Lamport algorithm
I The algorithm can be initiated by any process by executing
the ”Marker Sending Rule” by which it records its local state
and sends a marker on each outgoing channel.
I A process executes the ”Marker Receiving Rule” on receiving
a marker. If the process has not yet recorded its local state, it
records the state of the channel on which the marker is
received as empty and executes the ”Marker Sending Rule” to
record its local state.
I The algorithm terminates after each process has received a
marker on all of its incoming channels.
I All the local snapshots get disseminated to all other processes
and all the processes can determine the global state.
11 / 18
Introduction System model and definitions Snapshot algorithm for FIFO channels Non-FIFO channels
Chandy-Lamport algorithm
1: Process pi records its state
2: for each outgoing channel C on which a marker has not been
sent do
3: pi sends a marker along C before pi sends further messages
along C
4: end for
5: Marker receiving rule for process pj
6: On receiving a marker along channel C:
7: if Pj has not recorded its state then
8: Record the state of C as the empty set
9: Execute the ”marker sending rule”
10: else
11: Record the state of C as the set of messages received along
C after pj ’s state recorded and before pj received the marker
along C.
12: end if
12 / 18
Introduction System model and definitions Snapshot algorithm for FIFO channels Non-FIFO channels
Example
13 / 18
Introduction System model and definitions Snapshot algorithm for FIFO channels Non-FIFO channels
Correctness
I Due to FIFO property of channels, it follows that no message sent
after the marker on that channel is recorded in the channel state. Thus,
condition C2 is satisfied.
I When a process pj receives message mij that precedes the marker on
channel Cij , it acts as follows: If process pj has not taken its snapshot
yet, then it includes mij in its recorded snapshot. Otherwise, it records
mij in the state of the channel Cij . Thus, condition C1 is satisfied.
Complexity
I The recording part of a single instance of the algorithm requires O(e)
messages and O(d) time, where e is the number of edges in the network
and d is the diameter of the network.
14 / 18
Introduction System model and definitions Snapshot algorithm for FIFO channels Non-FIFO channels
15 / 18
Introduction System model and definitions Snapshot algorithm for FIFO channels Non-FIFO channels
16 / 18
Introduction System model and definitions Snapshot algorithm for FIFO channels Non-FIFO channels
17 / 18
Introduction System model and definitions Snapshot algorithm for FIFO channels Non-FIFO channels
18 / 18