Logical Clocks (2).

Slides:



Advertisements
Similar presentations
1 Concurrency: Deadlock and Starvation Chapter 6.
Advertisements

1 Process groups and message ordering If processes belong to groups, certain algorithms can be used that depend on group properties membership create (
Time, Clocks, and the Ordering of Events in a Distributed System
COS 461 Fall 1997 Time and Clocks u uses of time in distributed systems: –time-based algorithms (e.g. in security) –distributed make –gathering event traces.
Chapter 12 Message Ordering. Causal Ordering A single message should not be overtaken by a sequence of messages Stronger than FIFO Example of FIFO but.
Global States.
Last Class: Clock Synchronization
CS425/CSE424/ECE428 – Distributed Systems – Fall 2011 Material derived from slides by I. Gupta, M. Harandi, J. Hou, S. Mitra, K. Nahrstedt, N. Vaidya.
CSE 486/586, Spring 2014 CSE 486/586 Distributed Systems Reliable Multicast Steve Ko Computer Sciences and Engineering University at Buffalo.
CS542 Topics in Distributed Systems Diganta Goswami.
Replication. Topics r Why Replication? r System Model r Consistency Models r One approach to consistency management and dealing with failures.
Time and Global States Part 3 ECEN5053 Software Engineering of Distributed Systems University of Colorado, Boulder.
Synchronization Chapter clock synchronization * 5.2 logical clocks * 5.3 global state * 5.4 election algorithm * 5.5 mutual exclusion * 5.6 distributed.
Consistency and Replication (3). Topics Consistency protocols.
Dr. Kalpakis CMSC 621, Advanced Operating Systems. Logical Clocks and Global State.
Distributed Systems Spring 2009
CMPT 431 Dr. Alexandra Fedorova Lecture VIII: Time And Global Clocks.
Distributed Systems Fall 2009 Logical time, global states, and debugging.
Group Communications Group communication: one source process sending a message to a group of processes: Destination is a group rather than a single process.
CPSC 668Set 12: Causality1 CPSC 668 Distributed Algorithms and Systems Fall 2009 Prof. Jennifer Welch.
EEC 693/793 Special Topics in Electrical Engineering Secure and Dependable Computing Lecture 13 Wenbing Zhao Department of Electrical and Computer Engineering.
Lecture 13 Synchronization (cont). EECE 411: Design of Distributed Software Applications Logistics Last quiz Max: 69 / Median: 52 / Min: 24 In a box outside.
Lecture 12 Synchronization. EECE 411: Design of Distributed Software Applications Summary so far … A distributed system is: a collection of independent.
Computer Science Lecture 10, page 1 CS677: Distributed OS Last Class: Clock Synchronization Physical clocks Clock synchronization algorithms –Cristian’s.
Time, Clocks, and the Ordering of Events in a Distributed System Leslie Lamport (1978) Presented by: Yoav Kantor.
Distributed Systems Foundations Lecture 1. Main Characteristics of Distributed Systems Independent processors, sites, processes Message passing No shared.
Dr. Kalpakis CMSC 621, Advanced Operating Systems. Fall 2003 URL: Logical Clocks and Global State.
Chapter 17 Theoretical Issues in Distributed Systems
Logical Clocks (2). Topics r Logical clocks r Totally-Ordered Multicasting r Vector timestamps.
Computer Science 425 Distributed Systems (Fall 2009) Lecture 5 Multicast Communication Reading: Section 12.4 Klara Nahrstedt.
Tanenbaum & Van Steen, Distributed Systems: Principles and Paradigms, 2e, (c) 2007 Prentice-Hall, Inc. All rights reserved DISTRIBUTED SYSTEMS.
Tanenbaum & Van Steen, Distributed Systems: Principles and Paradigms, 2e, (c) 2007 Prentice-Hall, Inc. All rights reserved DISTRIBUTED SYSTEMS.
Chapter 5.
CIS 720 Distributed algorithms. “Paint on the forehead” problem Each of you can see other’s forehead but not your own. I announce “some of you have paint.
Donghyun (David) Kim Department of Mathematics and Physics North Carolina Central University 1 Project Reference Some slides are in courtesy of Dr. Erciyes,
Logical Clocks n event ordering, happened-before relation (review) n logical clocks conditions n scalar clocks condition implementation limitation n vector.
Page 1 Logical Clocks Paul Krzyzanowski Distributed Systems Except as otherwise noted, the content of this presentation is.
Tanenbaum & Van Steen, Distributed Systems: Principles and Paradigms, 2e, (c) 2007 Prentice-Hall, Inc. All rights reserved DISTRIBUTED SYSTEMS.
Logical Clocks. Topics Logical clocks Totally-Ordered Multicasting Vector timestamps.
Lamport’s Logical Clocks & Totally Ordered Multicasting.
Synchronization Chapter 5.
Communication & Synchronization Why do processes communicate in DS? –To exchange messages –To synchronize processes Why do processes synchronize in DS?
Distributed Systems Fall 2010 Logical time, global states, and debugging.
Replication (1). Topics r Why Replication? r System Model r Consistency Models – How do we reason about the consistency of the “global state”? m Data-centric.
Event Ordering Greg Bilodeau CS 5204 November 3, 2009.
CIS825 Lecture 2. Model Processors Communication medium.
Replication (1). Topics r Why Replication? r System Model r Consistency Models r One approach to consistency management and dealing with failures.
D u k e S y s t e m s Asynchronous Replicated State Machines (Causal Multicast and All That) Jeff Chase Duke University.
Logical Clocks. Topics Logical clocks Totally-Ordered Multicasting Vector timestamps.
DISTRIBUTED SYSTEMS Principles and Paradigms Second Edition ANDREW S
Building Dependable Distributed Systems, Copyright Wenbing Zhao
Tanenbaum & Van Steen, Distributed Systems: Principles and Paradigms, 2e, (c) 2007 Prentice-Hall, Inc. All rights reserved DISTRIBUTED SYSTEMS.
Logical Clocks. Topics r Logical clocks r Totally-Ordered Multicasting.
Event Ordering. CS 5204 – Operating Systems2 Time and Ordering The two critical differences between centralized and distributed systems are: absence of.
COMP 655: Distributed/Operating Systems Summer 2011 Dr. Chunbo Chu Week 6: Synchronyzation 3/5/20161 Distributed Systems - COMP 655.
6.2 Logical Clocks Kranthi Koya09/23/2015. Overview Introduction Lamport’s Logical Clocks Vector Clocks Research Areas Conclusion.
Fault Tolerance (2). Topics r Reliable Group Communication.
Logical Clocks event ordering, happened-before relation (review) logical clocks conditions scalar clocks  condition  implementation  limitation vector.
Slides for Chapter 11: Coordination and Agreement From Coulouris, Dollimore and Kindberg Distributed Systems: Concepts and Design Edition 3, © Addison-Wesley.
Logical time Causality between events is fundamental to the design of parallel and distributed systems. In distributed systems, it is not possible to have.
CSC 8320 Advanced Operating System
Distributed Mutex EE324 Lecture 11.
Overview of Ordering and Logical Time
SYNCHORNIZATION Logical Clocks.
Computer Science 425 Distributed Systems CS 425 / ECE 428 Fall 2013
Concurrent Graph Exploration with Multiple Robots
Chapter 5 (through section 5.4)
Lecture 9: Ordered Multicasting
CSE 486/586 Distributed Systems Reliable Multicast --- 1
Presentation transcript:

Logical Clocks (2)

Topics Logical clocks Totally-Ordered Multicasting Vector timestamps

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.

Problems with Lamport Clocks Lamport timestamps do not capture causality. With Lamport’s clocks, one cannot directly compare the timestamps of two events to determine their precedence relationship. If C(a) < C(b) is not true then a  b is also not true. Knowing that C(a) < 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) < C(b) but it is not the case that e  b

Problems with Lamport Clocks Why is this important? For the banking example, it doesn’t 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

Example Application:Bulletin Board The Internet’s electronic bulletin board (or Google’s Groups or any chat service) 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 we be doing this?

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 (more on this later) Ordering: total (makes the numbers the same at all sites) Bulletin board: os.interesting causal (makes replies come after original message) Item From Subject 23 A.Hanlon Mach FIFO (gives sender order) 24 G.Joseph Microkernels 25 A.Hanlon Re: Microkernels 26 T.L’Heureux RPC performance Figure 11.13 Colouris 27 M.Walker Re: Mach end •

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. 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.

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.

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. Fidge’s 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.

Vector Timestamps 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

Vector Timestamps A vector 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 of interest (in our case this will be a send event) in a process, q i.e., vq[q] = vq[q] +1 Let vq be piggybacked on the message sent by process q to process p; We then have: For i = 1 to n do vp[i] = max(vp[i], vq [i] );

Vector Timestamp For two vector timestamps, va and vb va  vb if there exists an i such that va[i]  vb[i] va ≤ vb if for all i va[i] ≤ vb[i] va < vb if for all i va[i] ≤ vb[i] AND va is not equal to vb Events a and b are causally related if va < vb or vb< va . Vector timestamps can be used to guarantee causal message delivery.

Example Application: Bulletin Board Each process Pi has an array Vi where Vi[j] 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 Vi[j] = 6 then Pi knows that Pj has sent 6 messages.

Example Application: Bulletin Board Let Vi be piggybacked on the message sent by process Pi to process Pj ; When process Pj receives the message, then Pj does the following: For k = 1 to n do Vj[k] = max(Vi[k], Vj [k] ); Thus if process i knows that process k sent 5 messages (Vi [k] =5 and Vj[k] = 3) then process j didn’t know about the latest two messages sent by process k.

Example Application: Bulletin Board When process i sends a message, it does the following: Vi[i] = Vi[i] + 1; This is basically saying that the number of messages process i has sent is incremented by one.

Example Application: Bulletin Board When a process Pi posts (sends) an article, a, it multicasts that article with timestamp Vi Process Pj posts a reaction. Let’s call this message r. Assume that the value of the timestamp is Vj Note that Vj > 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 .

Example Application: Bulletin Board Message r (from Pj ) is delivered to Pk iff the following conditions are met: Vj[j] = Vk[j]+1 This condition is satisfied if r is the next message that Pk was expecting from process Pj Assume that Vk[j]=5. This means that Pk knows Pj sent 5 messages and that it should be waiting for the 6th message. If Vj[j] = 8 then messages 6,7 are lost or not yet arrived. Vj[i] ≤ Vk[i] 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 Vj[i] = 2 and Vk[i] =1 and thus Vj[i] > Vk[i] for some i. This indicates that Pi sent a message that was received by Pj but not Pk

Example Application: Bulletin Board [0,0,0] P1 [0,0,0] P3 [0,0,0] Post a [1,0,0] a [1,0,0] e [1,0,0] c [1,0,1] r: Reply a d g b [1,0,1] Note that if two events happen without any message, then we can't say anything about their relative occurrence in time. In this example a <= b <= c <= d <= f, but we can say little about e other than e <= f. We say that events such as a and e are concurrent. Note also that “happened before” does not demonstrate causality. There is merely the potential for causality. [1,0,1] Message a arrives at P2 before the reply r from P3 does

Example Application: Bulletin Board [0,0,0] P1 [0,0,0] P3 [0,0,0] Post a [1,0,0] a d [1,0,0] g [1,0,1] r: Reply a Buffered b Note that if two events happen without any message, then we can't say anything about their relative occurrence in time. In this example a <= b <= c <= d <= f, but we can say little about e other than e <= f. We say that events such as a and e are concurrent. Note also that “happened before” does not demonstrate causality. There is merely the potential for causality. 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.

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.