Logical Clocks 2 - PowerPoint PPT Presentation

About This Presentation
Title:

Logical Clocks 2

Description:

Causal order is used when a message received by a process can ... Knowing the absolute time is not necessary. Logical clocks can be used for ordering purposes. ... – PowerPoint PPT presentation

Number of Views:73
Avg rating:3.0/5.0
Slides: 24
Provided by: michae77
Category:

less

Transcript and Presenter's Notes

Title: Logical Clocks 2


1
Logical Clocks (2)
2
Topics
  • Logical clocks
  • Totally-Ordered Multicasting
  • Vector timestamps

3
Readings
  • Van Steen and Tanenbaum 5.2
  • Coulouris 10.4
  • L. Lamport, Time, Clocks and the Ordering of
    Events in Distributed Systems, Communications of
    the ACM, Vol. 21, No. 7, July 1978, pp. 558-565.
  • C.J. Fidge, Timestamps in Message-Passing
    Systems that Preserve the Partial Ordering,
    Proceedings of the 11th Australian Computer
    Science Conference, Brisbane, pp. 56-66, February
    1988.

4
Problems with Lamport Clocks
  • Lamport timestamps do not capture causality.
  • With Lamports clocks, one cannot directly
    compare the timestamps of two events to determine
    their precedence relationship.
  • If C(a) lt C(b) is not true then a ? b is also not
    true.
  • Knowing that C(a) lt C(b) is true does not allow
    us to conclude that a ? b is true.
  • Example In the first timing diagram, C(e) 1
    and C(b) 2 thus C(e) lt C(b) but it is not the
    case that e ? b

5
Problems with Lamport Clocks
  • Why is this important?
  • For the banking example, it doesnt matter what
    order operations are executed at each replica.
  • It only matters that all replicas execute the
    operations in the same order. This is total
    order.
  • Causal order is used when a message received by a
    process can potentially affect any subsequent
    message sent by that process. Those messages
    should be received in that order at all
    processes. Unrelated messages may be delivered
    in any order.
  • Do Lamport timestamps support causal order?
  • NO

6
Example ApplicationBulletin Board
  • The Internets electronic bulletin board service
    (network news)
  • Users (processes) join specific groups
    (discussion groups).
  • Postings, whether they are articles or reactions,
    are multicast to all group members.
  • Could use a totally-ordered multicasting scheme.
  • Should be doing this?

7
Display from a Bulletin Board Program
  • Users run bulletin board applications which
    multicast messages
  • One multicast group per topic (e.g.
    os.interesting)
  • Require reliable multicast - so that all members
    receive messages
  • Ordering

Bulletin board
os.interesting
From
Subject
Item
23
A.Hanlon
Mach


24
G.Joseph
Microkernels
25
A.Hanlon
Re Microkernels
26
T.LHeureux
RPC performance
Figure 11.13 Colouris
27
M.Walker
Re Mach
end

8
Example Application Bulletin Board
  • A totally-ordered multicasting scheme does not
    imply that if message B is delivered after
    message A, that B is a reaction to A.
  • Totally-ordered multicasting is too strong in
    this case.
  • The receipt of an article precedes the posting of
    a reaction.
  • The receipt of the reaction to an article should
    always follow the receipt of the article.

9
Example Application Bulletin Board
  • If we look at the bulletin board example, it is
    allowed to have items 26 and 27 in different
    order at different sites.
  • Items 25 and 26 may be in different order at
    different sites.

10
Problem with Lamport Clocks
  • The main problem is that a simple integer clock
    cannot order both events within a process and
    events in different processes.
  • C. Fidge developed an algorithm that overcomes
    this problem.
  • Fidges clock is represented as a vector
    v1,v2,,vn with an integer clock value for each
    process (vi contains the clock value of process
    i). This is a vector timestamp.

11
Fidges Algorithm
  • Properties of vector timestamps
  • vi i is the number of events that have occurred
    so far at Pi
  • If vi j k then Pi knows that k events have
    occurred at Pj

12
Fidges Algorithm
  • The Fidges logical clock is maintained as
    follows
  • Initially all clock values are set to the
    smallest value (e.g., 0).
  • The local clock value is incremented at least
    once before each event in a process, q i.e.,
    vqq vqq 1
  • Let vq be piggybacked on the message sent by
    process q to process p We then have
  • For i 1 to n do
  • vpi max(vpi, vq i )
  • vpp vpp 1

13
Fidges Algorithm
  • For two vector timestamps, va and vb
  • va ? vb if there exists an i such that vai ?
    vbi
  • va vb if for all i vai vbi
  • va lt vb if for all i vai vbi AND va is not
    equal to vb
  • Events a and b are causally related if va lt vb or
    vblt va .

14
Example
P2
P1
P3
0,1,0
e
a
1,0,0
0,0,1
j
b
2,0,0
f
2,2,0
k
3,0,0
c
0,0,2
g
2,3,2
d
4,0,0
2,4,2
h
0,0,3
l
i
4,5,2
15
Causality and Modified Vector Timestamps
  • What I just presented is the original Fidges
    vector timestamp.
  • With a slight adjustment, vector timestamps can
    be used to guarantee causal message delivery.
  • We will illustrate this adjustment, the
    definition of causality and the motivation
    through an example.

16
Example Application Bulletin Board
  • Vector timestamps can be used to guarantee causal
    message delivery.
  • Each process Pi has an array Vi where Vij
    denotes the number of events that process Pi
    knows have taken place for Pj.
  • In this application events refers to the
    sending of a message.
  • Thus if Vij 6 then Pi knows that Pj has sent
    6 messages.

17
Example Application Bulletin Board
  • Vector timestamps are assumed to be updated only
    when posting or receiving articles i.e., when a
    message is sent or received.
  • Let Vq be piggybacked on the message sent by
    process Pq to process Pp When process Pp
    receives the message, then Pp does the following
  • For i 1 to n do
  • Vpi max(Vpi, Vq i )
  • Thus if process q knows that process i sent 5
    messages (Vq i 5 and Vpi 3) then process p
    didnt know about the latest two messages sent by
    process i.

18
Example Application Bulletin Board
  • When p sends a message, it does the following
  • Vpp Vpp 1
  • This is basically saying that the number of
    messages process p has sent is incremented by
    one.

19
Example Application Bulletin Board
  • When a process Pi posts (sends) an article, it
    multicasts that article with timestamp Vi
  • Process Pj posts a reaction. Lets call this
    message r. Assume that the value of the timestamp
    is Vj
  • Note that Vj gt Vi
  • Message r may arrive at Pk before message a.
  • Pk will postpone delivery of r to the display of
    the bulletin board until all messages that
    causally precede r have been received as well.

20
Example Application Bulletin Board
  • Message r (from Pj ) is delivered to Pk iff the
    following conditions are met
  • Vjj Vkj1
  • This condition is satisfied if r is the next
    message that Pk was expecting from process Pj
  • Assume that Vkj5. This means that Pk knows Pj
    sent 5 messages and that it should be waiting for
    the 6th message.
  • If Vjj 8 then messages 6,7 are lost.
  • Vji Vki for all i not equal to j
  • This condition is satisfied if Pk has seen at
    least as many messages as seen by Pj when it sent
    message r.
  • Assume for some i that Vji 2 and Vki 1
    and thus Vji gt Vki for some i. This
    indicates that Pi sent a message that was
    received by Pj but not Pk

21
Example Application Bulletin Board
0,0,0
P2
P1
P3
0,0,0
0,0,0
Post a
1,0,0
a
e
1,0,0
1,0,0
c
1,0,1
r Reply a
d
g
b
1,0,1
1,0,1
Message a arrives at P2 before the reply r from
P3 does
22
Example Application Bulletin Board
0,0,0
P2
P1
P3
0,0,0
0,0,0
Post a
1,0,0
a
d
1,0,0
g
1,0,1
r Reply a
Buffered
b
c
1,0,1
1,0,0
Deliver r
The message a arrives at P2 after the reply from
P3 The reply is not delivered right away.
23
Summary
  • No notion of a globally shared clock.
  • Local (physical) clocks must be synchronized
    based on algorithms that take into account
    network latency.
  • Knowing the absolute time is not necessary.
  • Logical clocks can be used for ordering purposes.
Write a Comment
User Comments (0)
About PowerShow.com