Upload
willis
View
24
Download
0
Embed Size (px)
DESCRIPTION
Time And Global States. By Jeevan Varma Anga. Layout. Significance of Time. Definitions Some Algorithms. Significance. Consistent Electronic commerce transactions. To understand how distributed executions unfold. To determine global state. Events. - PowerPoint PPT Presentation
Citation preview
Time And Global States
By
Jeevan Varma Anga
Layout
Significance of Time. Definitions Some Algorithms
Significance Consistent Electronic commerce
transactions. To understand how distributed executions
unfold. To determine global state.
Events
An Event is an occurrence of a single action that a process carries out as it executes – a communication action or a state-transformation action.
History(pi)=<ei0,ei1,ei2,ei3…..>
Clocks
Electronic Devices that count oscillations occurring in a crystal at a definite frequency, and that typically divide this count and store the result in a counter register.
Clock Skew. Clock drift.
Synchronizing Physical Clocks
External Synchronization Internal Synchronization
Synchronization in a synchronous system (Internal Sync.):
One process sends the time t on its local clock to the other in a message m.
The receiving process could set its clock to the time t+TRANS where TRANS is the time taken to transmit m between them.
TRANS = min + x U(1-1/n) where u= (min+max)/2
Cristian’s method(External Sync.)
Uses a time server.
P Time Server, Smt
mr
P sets its time to t+Tround/2 Assumes that the elapsed time is split equally
before and after S sent placed t in mt
Berkeley Algorithm (Internal Sync.) A coordinator acts as master while others act
as slaves. Master polls slaves and receives their local
clock times. Master calculates average. Master sends the slaves + or – value. Faulty clocks are eliminated by identifying
significant adverse values. When a master fails, new master is elected.
Network Time Protocol(NTP)
NTP defines an architecture for a time service and a protocol to distribute time information over the internet.
Features: To provide a service enabling clients across the Internet to be synchronized accurately
to UTC. To provide a reliable service that can survive lengthy losses of connectivity. To enable clients to resynchronize sufficiently frequently to offset the rates of drift
found in most computers. To provide protection against interference with the time service, whether malicious or
accidental.
1
2 2
3 3 3 3
Strata Level 1
Strata Level 2
Strata Level 3
For each pair of messages sent between two servers, the NTP calculates an offset oi, which is an estimate of the actual offset between the two clocks, and a delay di, which is the total transmission time for the two messages.
di=t+t’=Ti-2 – Ti-3 + Ti – Ti-1
o=oi+(t’-t)/2 oi=(Ti-2 – Ti-3 + Ti – Ti-1)/2
Logical Time and Logical Clocks Lamport pointed out the issues of synchronizing
clocks perfectly. Happened-before relation (aka causal ordering
or potential causal ordering). Happened-before relation definition:
HB1: if process pi : e -> ie’, then e->e’ HB2: For any message m, send(m)-> receive(m) where send(m) is
the event of sending the message, and receive(m) is the event of receiving it.
HB3: If e,e’ and e’’ are events such that e->e’ and e’->e’’, then e->e’’
Logical Time and Logical Clocks
A Lamport logical clock is a monotonically increasing software counter, whose value need bear no particular relationship to any physical clock. LC1: Li is incremented before each event is issued at process pi. LC2: a)When a process pi sends a message m, it piggybacks on
m the value t=Li
b)On receiving(m,t), a process pj computes Lj:=max(Lj,t)
and then applies LC1 before timestamping the event
receive(m).
Logical Timestamps1 2
3 4
51
a bm1
c d
m2
fe
p1
p2
p3
PhysicalTime
Vector Timestamps(1,0,0) (2,0,0)
(2,1,0) (2,2,0)
(2,2,2)(0,0,1)
a bm1
c d
m2
fe
p1
p2
p3
PhysicalTime
Global States
Examples of applicability: Distributed garbage collection, distributed deadlock detection, distributed termination detection and distributed debugging.
Global states and consistent cuts: Collection of histories where history of a process is a sequence of totally ordered events at that process
A cut is consistent if, for each event it contains, it also contains all the events that happened-before that event.
Global state predicates, stability, safety, and liveness Global state predicate: F(State)--->{True,false} Stability: Once the system enters a state it never leaves it Predicate: Safety: For an undesirable property: If S0 is the
original state, then safety property w.r.t. α is the assertion that α evaluates to false for all states S reachable from S0.
Predicate: Liveness: For a desirable property (e.g. termination), liveness w.r.t. ß is the property that for any linearization L starting in S0, ß evaluates to True for some state SL reachable from S0.
The snapshot algorithm of Chandy and Lamport
To determine the global states of a distributed system Goal: Record a set of process and channel states for a set of
processes such that, even though the combination of recorded states may never have occurred at the same time, the recorded global state is consistent.
The algorithm assumes: neither channels nor processes fail channels are unidirectional and provide FIFO delivery the graph of processes and channels is strongly connected any process may initiate a global snapshot algorithm any time the processes continue their execution and send and receive
normal messages while the snapshot algorithm takes place
Snapshot AlgorithmMarker receiving rule for process pi On pi’s receipt of a marker message over channel c: if ( pi has not yet recorded its state) it records its process state now;
records the state of c as the empty set;turns on recording of messages arriving over other incoming channels;
elsePi records the state of c as the set of messages it has received over csince it saved its state.
end if
Marker sending rule for process pi After pi has recorded its state, for each outgoing channel c: pi sends one marker message over c (before it sends any other message over c).
Example
Example