distributed algorithms by nancy.a.lynch chapter 18 logical time by sudha elavarti

18
DISTRIBUTED ALGORITHMS By Nancy.A.Lynch Chapter 18 LOGICAL TIME By Sudha Elavarti

Upload: amie-powers

Post on 03-Jan-2016

213 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: DISTRIBUTED ALGORITHMS By Nancy.A.Lynch Chapter 18 LOGICAL TIME By Sudha Elavarti

DISTRIBUTED ALGORITHMS

By

Nancy.A.Lynch

Chapter 18

LOGICAL TIMEBy

Sudha Elavarti

Page 2: DISTRIBUTED ALGORITHMS By Nancy.A.Lynch Chapter 18 LOGICAL TIME By Sudha Elavarti

Introduction• Logical time is a notion used for simplifying

the job of programming an asynchronous network

• Logical time is an element of some fixed totally ordered set T={t1,t2…..}, which is to be assigned for every execution of an asynchronous network A

• Logical time of all events should respect all the dependencies among the events within a system A.

Page 3: DISTRIBUTED ALGORITHMS By Nancy.A.Lynch Chapter 18 LOGICAL TIME By Sudha Elavarti

Logical Time for Send/Receive Systems

• If a is an execution of an asynchronous send/receive network, then logical time for a is assigning a value of T={t1.t2…} to every event in a.

• Assumptions– Only universal reliable FIFO send/receive

channels are considered.– No internal events are considered

Page 4: DISTRIBUTED ALGORITHMS By Nancy.A.Lynch Chapter 18 LOGICAL TIME By Sudha Elavarti

Properties for assigning Logical time to S/R

1)No two events get assigned the same logical time.

2)The logical times of events at each process are strictly increasing, according to their order of occurrence in a.

3)The logical time of any send event is strictly smaller than that of the corresponding receive event.

4)For any t belongs to T, there are only finite many events that get assigned logical times smaller than t.

Page 5: DISTRIBUTED ALGORITHMS By Nancy.A.Lynch Chapter 18 LOGICAL TIME By Sudha Elavarti

Logical time for Broadcast Systems

• To define logical time for broadcast systems all the events are considered.

• For any execution a ,logical time assignment is assigning a value T to very event in a , in such a way as to satisfy same properties as for S/R systems except property 3 i.e;– The logical time of any bcast event is strictly

smaller than that of each corresponding receive event.

Page 6: DISTRIBUTED ALGORITHMS By Nancy.A.Lynch Chapter 18 LOGICAL TIME By Sudha Elavarti

Adding Logical Time to Asynchronous Algorithms

• Logical times are generated for the events of a given asynchronous S/R network algorithm A.

• The given algorithm A transforms into a new asynchronous S/R algorithm L(A).

• The transformation works process by process.

• Whenever a process of L(A) simulates a step of A, it also generates a logical time.

Page 7: DISTRIBUTED ALGORITHMS By Nancy.A.Lynch Chapter 18 LOGICAL TIME By Sudha Elavarti

Advancing the clock (1.Lamport-Time Transformation)

• In this algorithm local clocks are maintained and advanced when messages are received in order to keep them synchronized.

• Logical time domain T is a set of pairs (c,i) where c is a non-negative integer, i is a process index.

• The clock variable gets increased by at least 1 at every event that occurs at process i.

• The logical time of any event is defined to be the value of the clock variable immediately after the event, paired with process index i as a tie breaker

Page 8: DISTRIBUTED ALGORITHMS By Nancy.A.Lynch Chapter 18 LOGICAL TIME By Sudha Elavarti

Lamports time transformation contd...

• Send-The clock value of send event is attached as time stamp to the mesg being sent.

• Receive-For every receive event, i increases its clock variable larger than its previous value and than the timestamp of the mesg.

• LamportTime(A) satisfies all the properties of definition of logical time.

• LamportTime transformation can be easily modified to work in asynchronous broadcast systems.

Page 9: DISTRIBUTED ALGORITHMS By Nancy.A.Lynch Chapter 18 LOGICAL TIME By Sudha Elavarti

Delaying Future Events(2.WelchTime Transformation)

• Clocks are not advanced in response to mesg receipts, but mesg’s that arrive early are delayed.

• Domain T is a set of triples (c,i,k), where c is a nonnegative real, i process index, k belongs to N+.

• Logical time of any event is defined to be the value of the clock when the event occurs.

• Process i maintains a FIFO receive-buffer in order to hold mesg’s whose timestamps are greater than or equal to the local clock value.

Page 10: DISTRIBUTED ALGORITHMS By Nancy.A.Lynch Chapter 18 LOGICAL TIME By Sudha Elavarti

WelchTime contd..

• For every mesg if timestamp is less than current clock value, mesg is processed, else it is placed in receive-buffer, they are processed in the order in which they appear in the receive-buffer.

• The unbounded ness of the local clock variables also implies that every mesg in a receive-buffer is eventually processed.

• WelchTime(A) satisfies all the properties of definition of logical time.

• WelchTime transformation can be modified to work in asynchronous broadcast systems.

Page 11: DISTRIBUTED ALGORITHMS By Nancy.A.Lynch Chapter 18 LOGICAL TIME By Sudha Elavarti

ApplicationsBanking Systems

• For counting the total amount of money that is transferred between process via mesg.

• Each process has a local variable that money that contains current amount at that location.

• CountMoney algorithm transformed from algorithm A finds the local balance

Page 12: DISTRIBUTED ALGORITHMS By Nancy.A.Lynch Chapter 18 LOGICAL TIME By Sudha Elavarti

CountMoney Algorithm• It has a subroutine with predetermined logical

time t belongs to T, assuming t is known, general strategy is

1)For each process of A, determine the value of the money variable after all events with logical times less than or equal to t and before all events with logical times greater than t.

2)For each channel, determine the amount of money in all the messages sent at logical times less than or equal to t but received at logical times strictly greater than t.

Page 13: DISTRIBUTED ALGORITHMS By Nancy.A.Lynch Chapter 18 LOGICAL TIME By Sudha Elavarti

$10 $30$20

$4 $5

$3

$2

$1

1 2 3

2

10

7

6

3

41

85

9

Page 14: DISTRIBUTED ALGORITHMS By Nancy.A.Lynch Chapter 18 LOGICAL TIME By Sudha Elavarti

Global Snapshots

• CountMoney generalised to get an instantaneous global snapshot of system state.

• useful for debugging,in case of failure,or detecting certain global properties.

• it is possible to get a global snapshot by delaying process and mesg’s till it records all the needed information, but not practical.

• true global snapshot may not be needed, but a system state that “look-like” global snapshot to all processes is good enough.

Page 15: DISTRIBUTED ALGORITHMS By Nancy.A.Lynch Chapter 18 LOGICAL TIME By Sudha Elavarti

LogicalTimeSnapShot algorithm• As in CountMoney,it has a subroutine with

predetermined logical time t belongs to T, assuming t is known, general strategy is1)determine the state of each process of A after all events with logical times less than or equal to t and before all events with logical times greater then t.2)For each channel, determine the sequence of messages sent at logical times less than or equal to t but received at logical times strictly greater then t.

--this information is determined by same

distributed algo. (CountMoney)

Page 16: DISTRIBUTED ALGORITHMS By Nancy.A.Lynch Chapter 18 LOGICAL TIME By Sudha Elavarti

ReplicatedStateMachine Algorithm

• To simulate single state machine or single shared variable, say x.• Consider there are n user processes submitting invocations to x and

receiving responses from x.• One user process Ui at each node i of the network.• The network as a whole should be atomic object.• ALGO:- Each process Ai simply receives invocations from user Ui

and broadcasts them.• Each process has a local copy of x and a local variable invocation-

buffer in which it stores all invocations.• Process i places local invocation in its invocation-buffer when it

performs the broadcast and places remote invocation when it performs the receive for that invocation.

Page 17: DISTRIBUTED ALGORITHMS By Nancy.A.Lynch Chapter 18 LOGICAL TIME By Sudha Elavarti

Continued…

• Process i maintains a vector known-time, which keeps track of largest

local time for each process.– Known-time(i)i = logical time of most recent event at process i.– Known-time(j)i = logical time of broadcast event received by i

from j .

• Process i is permitted to apply an invocation pi in its invocation-buffer to its copy of x when following is true.– Invocation pi has the smallest logical time of any invocation in

invocation-buffer (i) .– For every j, known-time(j)i >= logical time of pi.

Page 18: DISTRIBUTED ALGORITHMS By Nancy.A.Lynch Chapter 18 LOGICAL TIME By Sudha Elavarti

Transforming Real-Time Algorithms to Logical-Time Algorithms

• S/R system A ,in which each process Ai has a real-time value

• Times occurring as arguments in its output event should be nondecreasing and unbounded in any fair execution.

• It is possible to transform each process Ai into a process Bi without real-time,but with logical time.