Documente Academic
Documente Profesional
Documente Cultură
Introduction
A DS is a collection of computers that are spatially separated and do not share a common memory Processes communicate by exchanging messages over communication channel Messages are delivered after an arbitrary transmission delay DS suffers some inherent limitations because of lack of common memory and a systemwide common clock How these limitations can be overcome?
Example
Local state of A Local state of B
(a)
$500 S1: A
Communication Channel
$200 S2: B
(b)
$450 S1: A
$200 S2: B
(c)
$500
S1: A
$250
7
causally affects event b if a b. CONCURRENT EVENTS: Two distinct events a and b are said to be concurrent (denoted by a||b) if a / b and b/ a. For any two events a and b in a system, either a , b a, or a||b
e11 P1
Space
e12
e13
e14
e21 P2
e22
e23
Global time
e24
The following implementation rules (IR) for the clocks guarantee that the clocks satisfy the correctness conditions Cl and C2:
[IR2] If event a is the sending of message m by process Pi, then message m is assigned a timestamp tm, = Ci(a) (note that the value of Ci(a) is obtained after applying rule IRI). On receiving the same message m by process Pj, Cj is set to a value greater than or equal to its present value and greater than tm Cj := max(Cj, tm + d) (d > 0)
e12
(2) (2)
e13
(3)
e14
(4) (3)
e15
(5)
e16
(6) (4)
e17
(7) (7)
(1) (1)
e21 P2
e22
e23
e24
e25
Global time
e12
(2)
e21
(1)
e22
(3)
P3
e31
(1)
e32
(2) Global time
e33
(3)
Vector Clock
The system of vector clocks was independently proposed by Fidge and Mattern:
Let n be the number of processes in a distributed system Each process Pi is equipped with a clock Ci(a), which is an integer vector of length n The clock Ci can be thought of as a function that assigns a vector Ci(a) to any event a Ci(a) is referred to as the timestamp of event e1 at Pi. Ci[I] the ith entry of Ci, corresponds to Pi's own logical time Ci[j] is Pi's best guess of the logical time at Pj. More specifically, at any point in time, the jth entry of Ci indicates the time of occurrence of the last event at Pj which "happened before" the current point in time at Pi This "happened before" relationship could be established directly by communication from Pj to Pi or indirectly through communication with other processes.
The figure illustrates an example of how clocks advance and the dissemination of time occurs in a system using vector clocks (d is assumed to be 1 and all clock values are initially zero) Thus, the system of vector clocks allows us to order events and decide whether two events are causally related or not by simply looking at the timestamps of the events If we know the processes where the events occur, the above test can be further simplified
(1,0,0)
(2,0,0)
(3,4,1)
P1
Space
e11
(0,1,0)
e12
(2,2,0) (2,3,1)
e13
(2,4,1)
P2 e21 P3
(0,0,1)
e22 e31
Global time
e23
(0,0,2)
e24 e32
Global State
Recording the consistent global state is a challenging task due to the absence of a global clock and shared memory A global state is a combination of local states of all machines and the channel A recorded global state may be inconsistent if n>n,
Where n is the number of messages sent by A along the channel before As state was recorded And, n is the number of messages sent by A along the channel before the channels state is recorded
Example
Local state of A Local state of B
(a)
$500 S1: A
C1:Empty
$200
S2: B
(b)
$450 S1: A
$200
C2:Empty C1:Empty
S2: B
(c)
$500
$250
C2:Empty
25
Definitions
Local State: For a site Si, its local state at a given time is defined by the local context of the distributed application, denoted by, LSi Global State: A global state GS of a system is a collection of the local states of its sites GS={LS1, LS2, LS3,,LSn{, where n is the no. of sites, in the system Consistent Global State: For every received message a corresponding sent event is recorded in the global state
Inconsistent global state: in an inconsistent global state, there is atleast one message whose received event is recorded but its send event is not recorded in the global state Transitless state: A global state is transitless if and only if, all communication channels are empty. Strongly consistent state: A state is strongly consistent if it is consistent and transitless
In a strongly consistent state, not only the send events of all the recorded received events are recorded, but the receive events of all the recorded send events are also recorded
Global State:
S1 S2 S3
LS11 LS21
LS31
LS32
LS32
Algorithm
Marker Sending Rule for a process P
P records its state For each outgoing channel C from P on which a marker has not been already sent, P sends a marker along C before P sends further messages along C