CS514: Intermediate Course in Operating Systems Professor Ken Birman Vivek Vishnumurthy: TA.

Slides:



Advertisements
Similar presentations
Logical Clocks.
Advertisements

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.
Time and synchronization (“There’s never enough time…”)
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.
Ken Birman Cornell University. CS5410 Fall
Distributed Systems 2006 Overcoming Failures in a Distributed System * *With material adapted from Ken Birman.
Ken Birman Cornell University. CS5410 Fall
Distributed Systems Spring 2009
CS514: Intermediate Course in Operating Systems Professor Ken Birman Vivek Vishnumurthy: TA.
Distributed systems Module 2 -Distributed algorithms Teaching unit 1 – Basic techniques Ernesto Damiani University of Bozen Lesson 3 – Distributed Systems.
CPSC 668Set 12: Causality1 CPSC 668 Distributed Algorithms and Systems Fall 2009 Prof. Jennifer Welch.
Teaching material based on Distributed Systems: Concepts and Design, Edition 3, Addison-Wesley Copyright © George Coulouris, Jean Dollimore, Tim.
Synchronization Clock Synchronization Logical Clocks Global State Election Algorithms Mutual Exclusion.
Distributed Systems Overview
Clock Synchronization Ken Birman. Why do clock synchronization?  Time-based computations on multiple machines Applications that measure elapsed time.
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 Clocks Ken Birman. Time: A major issue in distributed systems  We tend to casually use temporal concepts  Example: “p suspects that q has failed”
CSE 486/586, Spring 2012 CSE 486/586 Distributed Systems Logical Time Steve Ko Computer Sciences and Engineering University at Buffalo.
Distributed Systems: Time and Mutual Exclusion. 2 Distributed Systems Definition: Loosely coupled processors interconnected by network Distributed system.
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.
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.
CS514: Intermediate Course in Operating Systems Professor Ken Birman Vivek Vishnumurthy: TA.
Lecture 2-1 CS 425/ECE 428 Distributed Systems Lecture 2 Time & Synchronization Reading: Klara Nahrstedt.
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.
CSE 486/586, Spring 2013 CSE 486/586 Distributed Systems Logical Time Steve Ko Computer Sciences and Engineering University at Buffalo.
CS5412: REPLICATION, CONSISTENCY AND CLOCKS Ken Birman 1 CS5412 Spring 2014 (Cloud Computing: Birman) Lecture X.
Tanenbaum & Van Steen, Distributed Systems: Principles and Paradigms, 2e, (c) 2007 Prentice-Hall, Inc. All rights reserved Chapter 6 Synchronization.
Logical Clocks n event ordering, happened-before relation (review) n logical clocks conditions n scalar clocks condition implementation limitation n vector.
Issues with Clocks. Context The tree correction protocol was based on the idea of local detection and correction. Protocols of this type are complex to.
Synchronization. Why we need synchronization? It is important that multiple processes do not access shared resources simultaneously. Synchronization in.
Lamport’s Logical Clocks & Totally Ordered Multicasting.
CS514: Intermediate Course in Operating Systems Professor Ken Birman Krzys Ostrowski: TA.
CSC 536 Lecture 1. Outline Synchronization Clock synchronization Logical clocks Lamport timestamps Vector timestamps Global states and distributed snapshot.
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?
Real-Time & MultiMedia Lab Synchronization Distributed System Jin-Seung,KIM.
EEC 688/788 Secure and Dependable Computing Lecture 10 Wenbing Zhao Department of Electrical and Computer Engineering Cleveland State University
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.
CIS825 Lecture 2. Model Processors Communication medium.
D u k e S y s t e m s Asynchronous Replicated State Machines (Causal Multicast and All That) Jeff Chase Duke University.
DISTRIBUTED SYSTEMS Principles and Paradigms Second Edition ANDREW S
Building Dependable Distributed Systems, Copyright Wenbing Zhao
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.
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.
EEC 688/788 Secure and Dependable Computing Lecture 10 Wenbing Zhao Department of Electrical and Computer Engineering Cleveland State University
The consensus problem in distributed systems
Distributed Computing
CSE 486/586 Distributed Systems Logical Time
CSE 486/586 Distributed Systems Logical Time
Logical time (Lamport)
EEC 688/788 Secure and Dependable Computing
Chapter 5 (through section 5.4)
CDK: Sections 11.1 – 11.4 TVS: Sections 6.1 – 6.2
EEC 688/788 Secure and Dependable Computing
EEC 688/788 Secure and Dependable Computing
Logical time (Lamport)
CS514: Intermediate Course in Operating Systems
Logical time (Lamport)
CSE 486/586 Distributed Systems Logical Time
Logical time (Lamport)
Outline Theoretical Foundations
Presentation transcript:

CS514: Intermediate Course in Operating Systems Professor Ken Birman Vivek Vishnumurthy: TA

Recap We’ve started a process of isolating questions that arise in big systems Tease out an abstract issue Treat it separate from the original messy context Try and understand what can and cannot be done, and how to solve when something can be done

So far? Naming and discovery Performance through threading, events, ultimately clusters Notions of consistency that can and cannot be solved Can’t achieve common knowledge But if we accept certain very limited risks can often achieve reasonable goals

This and upcoming lectures? We’ll focus on concepts relating to time Time as it can be “used” in systems Systems that present behaviors best understood in terms of temporal models (notably the transactional model) Event ordering used to ensure consistency in distributed systems (multicasts that update replicated data or program state)

What time is it? In distributed system we need practical ways to deal with time E.g. we may need to agree that update A occurred before update B Or offer a “lease” on a resource that expires at time 10: Or guarantee that a time critical event will reach all interested parties within 100ms

But what does time “mean”? Time on a global clock? E.g. with GPS receiver … or on a machine’s local clock But was it set accurately? And could it drift, e.g. run fast or slow? What about faults, like stuck bits? … or could try to agree on time

Lamport’s approach Leslie Lamport suggested that we should reduce time to its basics Time lets a system ask “Which came first: event A or event B?” In effect: time is a means of labeling events so that… If A happened before B, TIME(A) < TIME(B) If TIME(A) < TIME(B), A happened before B

Drawing time-line pictures: p m snd p (m) q rcv q (m) deliv q (m) D

Drawing time-line pictures: A, B, C and D are “events”. Could be anything meaningful to the application So are snd(m) and rcv(m) and deliv(m) What ordering claims are meaningful? p m A C B snd p (m) q rcv q (m) deliv q (m) D

Drawing time-line pictures: A happens before B, and C before D “Local ordering” at a single process Write and p q m A C B rcv q (m) deliv q (m) snd p (m) D

Drawing time-line pictures: snd p (m) also happens before rcv q (m) “Distributed ordering” introduced by a message Write p q m A C B rcv q (m) deliv q (m) snd p (m) D

Drawing time-line pictures: A happens before D Transitivity: A happens before snd p (m), which happens before rcv q (m), which happens before D p q m D A C B rcv q (m) deliv q (m) snd p (m)

Drawing time-line pictures: B and D are concurrent Looks like B happens first, but D has no way to know. No information flowed… p q m D A C B rcv q (m) deliv q (m) snd p (m)

Happens before “relation” We’ll say that “A happens before B”, written A  B, if 1.A  P B according to the local ordering, or 2.A is a snd and B is a rcv and A  M B, or 3.A and B are related under the transitive closure of rules (1) and (2) So far, this is just a mathematical notation, not a “systems tool”

Logical clocks A simple tool that can capture parts of the happens before relation First version: uses just a single integer Designed for big (64-bit or more) counters Each process p maintains LT p, a local counter A message m will carry LT m

Rules for managing logical clocks When an event happens at a process p it increments LT p. Any event that matters to p Normally, also snd and rcv events (since we want receive to occur “after” the matching send) When p sends m, set LT m = LT p When q receives m, set LT q = max(LT q, LT m )+1

Time-line with LT annotations LT(A) = 1, LT(snd p (m)) = 2, LT(m) = 2 LT(rcv q (m))=max(1,2)+1=3, etc… p q m D A C B rcv q (m) deliv q (m) snd p (m) LT q LT p

Logical clocks If A happens before B, A  B, then LT(A)<LT(B) But converse might not be true: If LT(A)<LT(B) can’t be sure that A  B This is because processes that don’t communicate still assign timestamps and hence events will “seem” to have an order

Can we do better? One option is to use vector clocks Here we treat timestamps as a list One counter for each process Rules for managing vector times differ from what did with logical clocks

Vector clocks Clock is a vector: e.g. VT(A)=[1, 0] We’ll just assign p index 0 and q index 1 Vector clocks require either agreement on the numbering, or that the actual process id’s be included with the vector Rules for managing vector clock When event happens at p, increment VT p [index p ] Normally, also increment for snd and rcv events When sending a message, set VT(m)=VT p When receiving, set VT q =max(VT q, VT(m))

Time-line with VT annotations p q m D A C B rcv q (m) deliv q (m) snd p (m) VT q VT p VT(m)=[2,0] Could also be [1,0] if we decide not to increment the clock on a snd event. Decision depends on how the timestamps will be used.

Rules for comparison of VTs We’ll say that VT A ≤ VT B if  I, VT A [i] ≤ VT B [i] And we’ll say that VT A < VT B if VT A ≤ VT B but VT A ≠ VT B That is, for some i, VT A [i] < VT B [i] Examples? [2,4] ≤ [2,4] [1,3] < [7,3] [1,3] is “incomparable” to [3,1]

Time-line with VT annotations VT(A)=[1,0]. VT(D)=[2,4]. So VT(A)<VT(D) VT(B)=[3,0]. So VT(B) and VT(D) are incomparable p q m D A C B rcv q (m) deliv q (m) snd p (m) VT q VT p VT(m)=[2,0]

Vector time and happens before If A  B, then VT(A)<VT(B) Write a chain of events from A to B Step by step the vector clocks get larger If VT(A)<VT(B) then A  B Two cases: if A and B both happen at same process p, trivial If A happens at p and B at q, can trace the path back by which q “learned” VT A [p] Otherwise A and B happened concurrently

Introducing “wall clock time” There are several options “Extend” a logical clock or vector clock with the clock time and use it to break ties Makes meaningful statements like “B and D were concurrent, although B occurred first” But unless clocks are closely synchronized such statements could be erroneous! We use a clock synchronization algorithm to reconcile differences between clocks on various computers in the network

Synchronizing clocks Without help, clocks will often differ by many milliseconds Problem is that when a machine downloads time from a network clock it can’t be sure what the delay was This is because the “uplink” and “downlink” delays are often very different in a network Outright failures of clocks are rare…

Synchronizing clocks Suppose p synchronizes with time.windows.com and notes that 123 ms elapsed while the protocol was running… what time is it now? p time.windows.com What time is it? 09: Delay: 123ms

Synchronizing clocks Options? P could guess that the delay was evenly split, but this is rarely the case in WAN settings (downlink speeds are higher) P could ignore the delay P could factor in only “certain” delay, e.g. if we know that the link takes at least 5ms in each direction. Works best with GPS time sources! In general can’t do better than uncertainty in the link delay from the time source down to p

Consequences? In a network of processes, we must assume that clocks are Not perfectly synchronized. Even GPS has uncertainty, although small We say that clocks are “inaccurate” And clocks can drift during periods between synchronizations Relative drift between clocks is their “precision”

Thought question We are building an anti-missile system Radar tells the interceptor where it should be and what time to get there Do we want the radar and interceptor to be as accurate as possible, or as precise as possible?

Thought question We want them to agree on the time but it isn’t important whether they are accurate with respect to “true” time “Precision” matters more than “accuracy” Although for this, a GPS time source would be the way to go Might achieve higher precision than we can with an “internal” synchronization protocol!

Real systems? Typically, some “master clock” owner periodically broadcasts the time Processes then update their clocks But they can drift between updates Hence we generally treat time as having fairly low accuracy Often precision will be poor compared to message round-trip times

Clock synchronization To optimize for precision we can Set all clocks from a GPS source or some other time “broadcast” source Limited by uncertainty in downlink times Or run a protocol between the machines Many have been reported in the literature Precision limited by uncertainty in message delays Some can even overcome arbitrary failures in a subset of the machines!

For next time Read the introduction to Chapter 14 to be sure you are comfortable with notions of time and with notation Chapter 22 looks at clock synchronization