Distributed System Lecture 5
Distributed System Lecture 5
Prof. D. S. Yadav
Department of Computer Science 1
IET Lucknow
Distributed Computing: Principles, Algorithms, and Systems
INTRODUCTION
2
Distributed Computing: Principles, Algorithms, and Systems
C1 : Empty
500 200
C2 : Empty
Site S1 Site S2
Account A Account B
Global State A
3
Distributed Computing: Principles, Algorithms, and Systems
C1 : 50 ( In Transit)
450 200
C2 : Empty
Site S1 Site S2
Account A Account B
Global State B
4
Distributed Computing: Principles, Algorithms, and Systems
C1 : Empty
450 250
C2 : Empty
Site S1 Site S2
Account A Account B
Global State C
5
SNAPSHOT ALGORITHM: BANKINGEXAMPLE
SNAPSHOT ALGORITHM: BANKINGEXAMPLE
Distributed Computing: Principles, Algorithms, and Systems
SYSTEM MODEL
The system consists of a collection of n processes p1, p2, ..., pn that
are connected by channels.
There are no globally shared memory and physical global clock and
processes communicate by passing messages through communication
channels.
Cij denotes the channel from process pi to process pj and its state is
denoted by SCij .
The actions performed by a process are modeled as three types of
events: Internal events, the message send event and the message
receive event.
For a message mij that is sent by process pi to process pj , let
send (mij ) and rec (mij ) denote its send and receive events.
8
Distributed Computing: Principles, Algorithms, and Systems
SYSTEM MODEL
Transit: transit(LSi , LSj ) = {mij |send (mij ) LSi & rec (mij ) LSj }
9
GLOBAL STATE COLLECTION
Applications:
– Checking “stable” properties, checkpoint & recovery
Issues:
– Need to capture both node and channel states
– system cannot be stopped
– no global clock
Some notations:
– LSi: Local state of process I
– send(mij) : Send event of message mij from process i to process j
– rec(mij) : Similar, receive instead of send
– time(x) : Time at which state x was recorded
– time (send(m)) : Time at which send(m) occurred
10
DEFINITIONS
inconsistent(LSi, LSj) =
{ mij | send(mij) LSi & rec(mij) LSj }
11
DEFINITIONS
Global state: A Global State is defined as collection of local
states of its sites.
GS = {LS1, LS2,…, LSn}
12
Distributed Computing: Principles, Algorithms, and Systems
MODELS OF COMMUNICATION
Recall, there are three models of communication: FIFO, non-
FIFO, and CO.
In FIFO model, each channel acts as a first-in first-out
message queue and thus, message ordering is preserved by a
channel.
In non-FIFO model, a channel acts like a set in which the
sender process adds messages and the receiver process removes
messages from it in a random order.
A system that supports causal delivery of messages satisfies
the following property:
“For any two messages mij and mkj ,
if send (mij ) → send (mkj ), then rec (mij ) → rec (mkj )”.
13
Distributed Computing: Principles, Algorithms, and Systems
14
Distributed Computing: Principles, Algorithms, and Systems
15
Distributed Computing: Principles, Algorithms, and Systems
C1 C2
1 2 e3 e4
e1 e1 1 1
p
1 m1
4
e12 e22 e23 e2 m
m5
p2 4
m2
e1 e 23 e 33 e34 e35
p3 3
m3
e1 e2
4 4
p4
time
16
Distributed Computing: Principles, Algorithms, and Systems
17
Distributed Computing: Principles, Algorithms, and Systems
After a site has recorded its snapshot, it sends a marker, along all
of its outgoing channels before sending out any more messages.
19
CHANDY LAMPORT’S ALGORITHM CONTD..
20
NOTABLE POINTS
21
Distributed Computing: Principles, Algorithms, and Systems
CHANDY-LAMPORT ALGORITHM
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.
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.
The algorithm terminates after each process has received a
marker on all of its incoming channels.
All the local snapshots get disseminated to all other processes
and all the processes can determine the global state.
22
Distributed Computing: Principles, Algorithms, and Systems
CORRECTNESS ANDCOMPLEXITY
Correctness
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.
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
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.
23