Page 1 Logical Clocks Paul Krzyzanowski Distributed Systems Except as otherwise noted, the content of this presentation is.

Slides:



Advertisements
Similar presentations
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.
Advertisements

Last Class: Clock Synchronization
Logical Clocks (2).
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.
Distributed Computing
Time and Clock Primary standard = rotation of earth De facto primary standard = atomic clock (1 atomic second = 9,192,631,770 orbital transitions of Cesium.
1 Causality. 2 The “happens before” relation happens before (causes)
Page 1 Lecturer: Roohollah Abdipour Acknowledgment: Many of the slides are based on slides by Prof. Paul Krzyzanowski at Rutgers University,
Dr. Kalpakis CMSC 621, Advanced Operating Systems. Logical Clocks and Global State.
Distributed Systems Spring 2009
Distributed Systems Fall 2009 Logical time, global states, and debugging.
CPSC 668Set 12: Causality1 CPSC 668 Distributed Algorithms and Systems Fall 2009 Prof. Jennifer Welch.
Lecture 13 Synchronization (cont). EECE 411: Design of Distributed Software Applications Logistics Last quiz Max: 69 / Median: 52 / Min: 24 In a box outside.
Logical Time and Logical Clocks
Time, Clocks and the Ordering of Events in a Distributed System - by Leslie Lamport.
CSE 486/586, Spring 2012 CSE 486/586 Distributed Systems Logical Time Steve Ko Computer Sciences and Engineering University at Buffalo.
EEC-681/781 Distributed Computing Systems Lecture 10 Wenbing Zhao Cleveland State University.
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.
Lecture 9: Time & Clocks CDK4: Sections 11.1 – 11.4 CDK5: Sections 14.1 – 14.4 TVS: Sections 6.1 – 6.2 Topics: Synchronization Logical time (Lamport) Vector.
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.
Chapter 5.
CSE 486/586, Spring 2013 CSE 486/586 Distributed Systems Logical Time Steve Ko Computer Sciences and Engineering University at Buffalo.
Logical Clocks n event ordering, happened-before relation (review) n logical clocks conditions n scalar clocks condition implementation limitation n vector.
Synchronization. Why we need synchronization? It is important that multiple processes do not access shared resources simultaneously. Synchronization in.
Logical Clocks. Topics Logical clocks Totally-Ordered Multicasting Vector timestamps.
Lamport’s Logical Clocks & Totally Ordered Multicasting.
CSE 486/586 CSE 486/586 Distributed Systems Logical Time Steve Ko Computer Sciences and Engineering University at Buffalo.
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.
Event Ordering Greg Bilodeau CS 5204 November 3, 2009.
Distributed Coordination. Turing Award r The Turing Award is recognized as the Nobel Prize of computing r Earlier this term the 2013 Turing Award went.
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.
CS603 Clock Synchronization February 4, What is Clock Synchronization? All nodes agree on time What do we mean by time? –Monotonic –Any observation.
CS 3471 CS 347: Parallel and Distributed Data Management Notes13: Time and Clocks.
Feb 15, 2001CSCI {4,6}900: Ubiquitous Computing1 Announcements.
Page 1 Mutual Exclusion & Election Algorithms Paul Krzyzanowski Distributed Systems Except as otherwise noted, the content.
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.
Lecture 1: Logical and Physical Time with some Applications Anish Arora CSE 6333 Notes include material from Dr. Jeff Brumfield.
Ordering of Events in Distributed Systems UNIVERSITY of WISCONSIN-MADISON Computer Sciences Department CS 739 Distributed Systems Andrea C. Arpaci-Dusseau.
11-Jun-16CSE 542: Operating Systems1 Distributed systems Time, clocks, and the ordering of events in a distributed system Leslie Lamport. Communications.
Logical Clocks event ordering, happened-before relation (review) logical clocks conditions scalar clocks  condition  implementation  limitation vector.
CSE 486/586, Spring 2014 CSE 486/586 Distributed Systems Logical Time Steve Ko Computer Sciences and Engineering University at Buffalo.
CSCE 668 DISTRIBUTED ALGORITHMS AND SYSTEMS
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
SYNCHORNIZATION Logical Clocks.
Time and Clock Primary standard = rotation of earth
Time and Clock.
Logical time (Lamport)
Time and Clock.
Logical Clocks and Casual Ordering
Outline Theoretical Foundations
CS 425 / ECE 428  2013, I. Gupta, K. Nahrtstedt, S. Mitra, N. Vaidya, M. T. Harandi, J. Hou.
ITEC452 Distributed Computing Lecture 10 Time in a Distributed System
Basics of Distributed Systems
CDK: Sections 11.1 – 11.4 TVS: Sections 6.1 – 6.2
Logical time (Lamport)
Logical time (Lamport)
CSE 486/586 Distributed Systems Logical Time
Logical time (Lamport)
CSE 542: Operating Systems
Presentation transcript:

Page 1 Logical Clocks Paul Krzyzanowski Distributed Systems Except as otherwise noted, the content of this presentation is licensed under the Creative Commons Attribution 2.5 License.

Page 2 Logical clocks Assign sequence numbers to messages –All cooperating processes can agree on order of events –vs. physical clocks: time of day Assume no central time source –Each system maintains its own local clock –No total ordering of events No concept of happened-when

Page 3 Happened-before Lamport’s “happened-before” notation a  b event a happened before event b e.g.: a: message being sent, b: message receipt Transitive: if a  b and b  c then a  c

Page 4 Logical clocks & concurrency Assign “clock” value to each event –if a  b then clock(a) < clock(b) –since time cannot run backwards If a and b occur on different processes that do not exchange messages, then neither a  b nor b  a are true –These events are concurrent

Page 5 Event counting example Three systems: P 0, P 1, P 2 Events a, b, c, … Local event counter on each system Systems occasionally communicate

Page 6 Event counting example ab hi k P1P1 P2P2 P3P df g 3 c e 5 j

Page 7 Event counting example ab i k j P1P1 P2P2 P3P df g 3 c Bad ordering: e  h f  k h e 5

Page 8 Lamport’s algorithm Each message carries a timestamp of the sender’s clock When a message arrives: –if receiver’s clock < message timestamp set system clock to (message timestamp + 1) –else do nothing Clock must be advanced between any two events in the same process

Page 9 Lamport’s algorithm Algorithm allows us to maintain time ordering among related events –Partial ordering

Page 10 Event counting example ab i k j P1P1 P2P2 P3P df g 3 c h e 5

Page 11 Summary Algorithm needs monotonically increasing software counter Incremented at least when events that need to be timestamped occur Each event has a Lamport timestamp attached to it For any two events, where a  b: L(a) < L(b)

Page 12 Problem: Identical timestamps a  b, b  c, …:local events sequenced i  c, f  d, d  g, … :Lamport imposes a send  receive relationship Concurrent events (e.g., a & i) may have the same timestamp … or not ab hi k j P1P1 P2P2 P3P df g 3 c e 5

Page 13 Unique timestamps (total ordering) We can force each timestamp to be unique –Define global logical timestamp (T i, i) T i represents local Lamport timestamp i represents process number (globally unique) –E.g. (host address, process ID) –Compare timestamps: (T i, i) < (T j, j) if and only if T i < T j or T i = T j and i < j Does not relate to event ordering

Page 14 Unique (totally ordered) timestamps ab i k j P1P1 P2P2 P3P df g 3.1 c h e 5.1

Page 15 Problem: Detecting causal relations If L(e) < L(e’) –Cannot conclude that e  e’ Looking at Lamport timestamps –Cannot conclude which events are causally related Solution: use a vector clock

Page 16 Vector clocks Rules: 1.Vector initialized to 0 at each process V i [j] = 0 for i, j =1, …, N 2.Process increments its element of the vector in local vector before timestamping event: V i [i] = V i [i] +1 3.Message is sent from process P i with V i attached to it 4.When P j receives message, compares vectors element by element and sets local vector to higher of two values V j [i] = max(V i [i], V j [i]) for i=1, …, N

Page 17 Comparing vector timestamps Define V = V’ iff V [i ] = V’[i ] for i = 1 … N V  V’ iff V [i ]  V’[i ] for i = 1 … N For any two events e, e’ if e  e’ then V(e) < V(e’) Just like Lamport’s algorithm if V(e) < V(e’) then e  e’ Two events are concurrent if neither V(e)  V(e’) nor V(e’)  V(e)

Page 18 Vector timestamps ab cd fe (0,0,0) P1P1 P2P2 P3P3

Page 19 Vector timestamps ab cd fe (0,0,0) P1P1 P2P2 P3P3 (1,0,0) Eventtimestamp a(1,0,0)

Page 20 Vector timestamps ab cd fe (0,0,0) P1P1 P2P2 P3P3 (1,0,0) Eventtimestamp a(1,0,0) b(2,0,0) (2,0,0)

Page 21 Vector timestamps ab cd fe (0,0,0) P1P1 P2P2 P3P3 (1,0,0) Eventtimestamp a(1,0,0) b(2,0,0) c(2,1,0) (2,0,0) (2,1,0)

Page 22 Vector timestamps ab cd fe (0,0,0) P1P1 P2P2 P3P3 (1,0,0) Eventtimestamp a(1,0,0) b(2,0,0) c(2,1,0) d(2,2,0) (2,0,0) (2,1,0)(2,2,0)

Page 23 Vector timestamps ab cd fe (0,0,0) P1P1 P2P2 P3P3 (1,0,0) Eventtimestamp a(1,0,0) b(2,0,0) c(2,1,0) d(2,2,0) e(0,0,1) (2,0,0) (2,1,0)(2,2,0) (0,0,1)

Page 24 Vector timestamps ab cd fe (0,0,0) P1P1 P2P2 P3P3 (1,0,0) Eventtimestamp a(1,0,0) b(2,0,0) c(2,1,0) d(2,2,0) e(0,0,1) f(2,2,2) (2,0,0) (2,1,0)(2,2,0) (0,0,1)(2,2,2)

Page 25 (0,0,1) (1,0,0) Vector timestamps ab cd fe (0,0,0) P1P1 P2P2 P3P3 Eventtimestamp a(1,0,0) b(2,0,0) c(2,1,0) d(2,2,0) e(0,0,1) f(2,2,2) (2,0,0) (2,1,0)(2,2,0) (2,2,2) concurrent events

Page 26 Vector timestamps ab cd fe (0,0,0) P1P1 P2P2 P3P3 (1,0,0) Eventtimestamp a(1,0,0) b(2,0,0) c(2,1,0) d(2,2,0) e(0,0,1) f(2,2,2) (2,0,0) (2,1,0)(2,2,0) (0,0,1)(2,2,2) concurrent events

Page 27 Vector timestamps ab cd fe (0,0,0) P1P1 P2P2 P3P3 (1,0,0) Eventtimestamp a(1,0,0) b(2,0,0) c(2,1,0) d(2,2,0) e(0,0,1) f(2,2,2) (2,0,0) (2,1,0)(2,2,0) (0,0,1)(2,2,2) concurrent events

Page 28 Vector timestamps ab cd fe (0,0,0) P1P1 P2P2 P3P3 (1,0,0) Eventtimestamp a(1,0,0) b(2,0,0) c(2,1,0) d(2,2,0) e(0,0,1) f(2,2,2) (2,0,0) (2,1,0)(2,2,0) (0,0,1)(2,2,2) concurrent events

Page 29 Summary: Logical Clocks & Partial Ordering Causality –If a->b then event a can affect event b Concurrency –If neither a->b nor b->a then one event cannot affect the other Partial Ordering –Causal events are sequenced Total Ordering –All events are sequenced

Page 30 The end.