Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
1
Introduction
2
Outline
3
Definitions (1)
4
Definitions (2)
e22
p2
e21 e23
p3
e31 e32 e33 e34 e35 e36
5
Definitions (3)
6
Example
p3
e31 e32 e33 e34 e35 e36
C C’
7
Consistency
8
Observing Distributed Computations
A monitor p0 will assume a passive role in that it will not send
any messages of its own
The application processes notify p0 by sending it a message
whenever they execute an event
The monitor p0 constructs an observation of the underlying
distributed computation as the events arrived
Due to the variability of message delays, an observation can
correspond to a consistent run, an inconsistent run or no run at all
O1 = e21e11e31e32e34e12e22e33e13e14e35.... => not a run
O2 = e11e31e21e32e12e33e34e13e22e35e36.... => inconsistent run
O3 = e31e21e11e12e32e33e13e34e14e22e15.... => consistent run
To restore order of messages by defining a delivery rule for
deciding when received messages are to be presented to the
application process
9
FIFO delivery
First-In-First-Out(FIFO) delivery
for all messages m and m' from pi to pj
if sendi(m) sendi(m') => deliverj(m) deliverj(m')
FIFO can be implemented by adding sequence numbers to
messages
While FIFO delivery is sufficient to guarantee that observations
correspond to runs, it is not sufficient to guarantee consistent
observations
10
Observing Distributed Computations
with Real-Time Clocks
Environment:
message delays are bounded by
channels are FIFO
existence of a global real-time clock
each message includes RC(e), the global real-time clock when event
e occurs, as its timestamp
DR1:
At time t, deliver all received messages with timestatmps up to t- in
increasing timestamp order
Observation is consistent iff the following is satisfied
Clock condition: e e' => RC(e) < RC(e')
11
Observing Distributed Computations
with Logical Clocks
Environment:
channels are FIFO
asynchronous communication
implementation of logical clocks
each message includes LC(e), the logical clock when event e occurs,
as its timestamp
DR2:
Deliver all messages that are stable at p0 in increasing timestamp
order
Note: a message m is stable at p if no future messages with
timestamp < TS(m)
Given FIFO channels, m is stable at p0 when p0 has received at least
one message with timestamp>TS(m) from all other processes
12
Logical Clocks
Logical Clock
each process pi maintains a local variable LCi
when a new event ei occurs, pi modifies LCi to
LCi + 1 if ei is an internal or send event
max{ LCi, TS(m)} + 1 if ei = receive(m)
1 2 4 5 6 7
p1
5
p2
1 6
p3
1 2 3 4 5 7
13
Observing Distributed Computations
with Causal Delivery
14
Efficient Delivering
15
Causal History (1)
e22
p2
e21 e23
p3
e31 e3 2 e33 e34 e35 e36
Causal history of event e14
16
Causal Histories (2)
Maintaining Causal History
Each process pi initializes local variable i to be
Each message m contains a timestamp TS(m) which is the causal
history of its send event
Scheme
If ei is internal or send event,
then i={ei} the causal history of the previous local event
If ei is the receive of message m by process pi from pj
then i={ei} the causal history of the previous local event of pi
the causal history of the corresponding send event at pj
The strong clock condition is satisfied if clock comparison is
interpreted as set inclusion
e e' (e) (e') or e e' e (e') if e e'
Problem: the causal histories will grow rapidly
17
Vector Clocks
p2 (1,2,4)
(0,1,0) (4,3,4)
p3
(0,0,1) (1,0,2) (1,0,3) (1,0,4) (1,0,5) (1,0,6)
18
Maintaining Vector Clocks
if ei = receive(m)
VCi = max { VCi , TS(m) }
19
Properties of Vector Clocks
21
Causal Delivery with vector Clock
Examples
p1 (1,0) (2,2)
(0,0) (3,2)
p2
(0,0) (1,1) (1,2)
22
Distributed Snapshots
23
Snapshot Protocol 1
Assumption:
existence of a global real-time clock : RC
Each message is attached with timestamp
Message delays are bounded
global clock algorithm
P0 sends [take snapshot at tss] to all processes
When clock RC reads tss, each process pi do the following
records its local state i,
sends an empty message over all its outgoing channels
and starts recording all message received over each incoming channels
For the time pi receives a message from pj with timestamp greater
than or equal to tss, pi stops recording messages for that channel
24
Snapshot Protocol 2
Assumption:
Bounded message delays
Channels are FIFO
Chandy & Lamport
P0 send [take snapshot] to itself
For each process pi receiving [take snapshot]
If it is the first time
records its local state i
sends each out-going channels [take snapshot]
starts recording messages from other incoming channels
If it is not the first time
stops recording message from that incoming channel
25
Chandy & Lamport (1985)
p0
26
Properties of Snapshots
Definition
a : the global state in which the snapshot protocol is initiated,
f : the global state in which the protocol terminates and
S : the global state constructed
ei* denote the event when pi receives [take snapshot] for the first
time, causing pi to start recording its state
let the time be ti when ei* occurs
ei is a prerecordering event if ei ei* ,
otherwise it is a post-recording event
Properties
Then there exists a run R' such that a S f
That is to say S could have happened
27
Argumentation (1)
28
Argumentation (2)
29
Properties of Global Predicates
Stable Predicates
Many system properties one wishes to detect have the characteristic
that once they become true, they remain true
If is a stable predicate, since a S f
( is true in s ) => ( is true in f )
( is false in s ) =>( is false in a )
Nonstable Predicates
the condition encoded by the predicate may not persist long enough
for it to be true when the predicate is evaluated
if a predicate is found to be true by the monitor, we do not know
whether ever held during the actual run
30
Nonstable Predicates
Two problems
The condition encoded by the predicate may not persist long
enough for it to be true when the predicate is evaluated
If a predicate is found to be true by the monitor, we do not
know whether ever held during the actual run
The predicate may have held even if it is not detected, and even if
it is detected it may have never held.
Extended nonstable global predicate: apply to the entire
distributed computation
Possibly()
Definitely()
31
Detecting Possibly and Definitely
min (ik) : the global state with the smallest level in the lattice
containing ik
max(ik) : the global state with the largest level in the lattice
containing ik
Examples: min (13) = 31,max (13) = 33
min(ik) = (1c1, 2c2,…, ncn ): j: VC(jcj)[j]=VC( ik)[j]
max(ik) = (1c1, 2c2,…, ncn ): j: VC(jcj)[i]<=VC( ik)[i]
and ((jCj = jf) or (VC(jCj+1)[i] > VC(jk)[i]))
The minimum level containing jk is the sum of components of
the vector timestamp VC(jk)
An algorithm for detecting Definitely(): O(kn): k is the
maximum number of events a monitored process has executed
32
Example
33