Logical Clocks n event ordering, happened-before relation (review) n logical clocks conditions n scalar clocks condition implementation limitation n vector.

Slides:



Advertisements
Similar presentations
Last Class: Clock Synchronization
Advertisements

CS4231 Parallel and Distributed Algorithms AY 2006/2007 Semester 2 Lecture 6 Instructor: Haifeng YU.
CS4231 Parallel and Distributed Algorithms AY 2006/2007 Semester 2 Lecture 4 Instructor: Haifeng YU.
Virtual Time “Virtual Time and Global States of Distributed Systems” Friedmann Mattern, 1989 The Model: An asynchronous distributed system = a set of processes.
SES Algorithm SES: Schiper-Eggli-Sandoz Algorithm. No need for broadcast messages. Each process maintains a vector V_P of size N - 1, N the number of processes.
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.
Theoretical Aspects Logical Clocks Causal Ordering
Dr. Kalpakis CMSC 621, Advanced Operating Systems. Logical Clocks and Global State.
Distributed Systems Spring 2009
Ordering and Consistent Cuts Presented By Biswanath Panda.
CMPT 431 Dr. Alexandra Fedorova Lecture VIII: Time And Global Clocks.
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.
Distributed Systems CS Synchronization – Part II Lecture 8, Sep 28, 2011 Majd F. Sakr, Vinay Kolar, Mohammad Hammoud.
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
Ordering and Consistent Cuts Presented by Chi H. Ho.
CSE 486/586, Spring 2012 CSE 486/586 Distributed Systems Logical Time Steve Ko Computer Sciences and Engineering University at Buffalo.
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.
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.
Donghyun (David) Kim Department of Mathematics and Physics North Carolina Central University 1 Project Reference Some slides are in courtesy of Dr. Erciyes,
1 Consistent Global States of Distributed Systems: Fundamental Concepts and Mechanisms Author: Ozalp Babaoglu and Keith Marzullo Distributed Systems: 526.
1 Causal Delivery Advanced Networks PhD. Saúl Pomares Hernández.
Page 1 Logical Clocks Paul Krzyzanowski Distributed Systems Except as otherwise noted, the content of this presentation is.
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.
Logical Clocks. Topics Logical clocks Totally-Ordered Multicasting Vector timestamps.
Lamport’s Logical Clocks & Totally Ordered Multicasting.
“Virtual Time and Global States of Distributed Systems”
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.
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.
Logical Clocks. Topics Logical clocks Totally-Ordered Multicasting Vector timestamps.
D ISTRIBUTED S YSTEM UNIT-2 Theoretical Foundation for Distributed Systems Prepared By: G.S.Mishra.
Lamport's Scalar clocks and Singhal-Kshemkalyani’s VC Algorithms
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.
Clock Snooping and its Application in On-the-fly Data Race Detection Koen De Bosschere and Michiel Ronsse University of Ghent, Belgium Taipei, TaiwanDec.
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
Overview of Ordering and Logical Time
SYNCHORNIZATION Logical Clocks.
COT 5611 Operating Systems Design Principles Spring 2012
Distributed Systems CS
Logical Clocks and Casual Ordering
Event Ordering.
Outline Theoretical Foundations
CS 425 / ECE 428  2013, I. Gupta, K. Nahrtstedt, S. Mitra, N. Vaidya, M. T. Harandi, J. Hou.
Distributed Systems CS
Chapter 5 (through section 5.4)
Distributed Systems CS
by Manas Hardas for Advanced Operating Systems Nov 27th 2007
COT 5611 Operating Systems Design Principles Spring 2014
Outline Theoretical Foundations
Presentation transcript:

Logical Clocks n event ordering, happened-before relation (review) n logical clocks conditions n scalar clocks condition implementation limitation n vector clocks condition implementation application – causal ordering of messages F birman-schiper-stephenson F schiper-eggli-sandoz n matrix clocks

Causality Relationship (Review) n an event is usually influenced by part of the state. n two consecutive events influencing disjoint parts of the state are independent and can occur in reverse order this intuition is captured in the notion of causality relation  (  ) n for message-passing systems: if two events e and f are different events of the same process and e occurs before f then e  f if s is a send event and r is a receive event then s  r n for shared memory systems: two operations on the same data item one of which is a write are causally related n  is a irreflexive partial order (i.e. the relation is transitive and antisymmetric, what does it mean?) give an example of a relation that is not a partial order if not a  b or b  a then a and b are concurrent: a || b n two computations are equivalent (have the same effect) if they only differ by the order of concurrent operations

Logical Clocks to implement “  ” in a distributed system, Lamport (1978) introduced the concept of logical clocks, which captures “  ” numerically each process P i has a logical clock C i process P i can assign a value of C i to an event a : step, or statement execution the assigned value is the timestamp of this event, denoted C(a) n the timestamps have no relation to physical time, hence the term logical clock n the timestamps of logical clocks are monotonically increasing n logical clocks run concurrently with application, implemented by counters at each process n additional information piggybacked on application messages

Conditions and Implementation Rules n conditions consistency: if a  b, then C(a)  C(b)  if event a happens before event b, then the clock value (timestamp) of a should be less than the clock value of b strong consistency: consistency and  if C(a)  C(b) then a  b n implementation rules: R1: how logical clock updated by process when it executes local event R2: what information is carried by message and how clock is updated when message is received

Implementation of Scalar Clocks the clock at each process P i is an integer variable C i implementation rules R1:before executing event update C i C i := C i + d (d>0) if d=1, C i is equal to the number of events causally preceding this one in the computation n R2:attach timestamp of the send event to the transmitted message when received, timestamp of receive event is computed as follows: C i := max(C i, C msg ) execute R1

Scalar Clocks Example n evolution of scalar time P1P1 e11 (1) e12 (2) e13 (3) e14 (4) e15 (5) e16 (6) e17 (7) P2P2 e21 (1) e22 (2) e23 (3) e24 (4) e25 (7)

Imposing Total Order with Scalar Clocks n total order is needed to form a computation total order (  ) can be imposed on partial order events as follows if a is any event in process P i, and b is any event in process P k, then a  b if either: C i (a)  C k (b) or C i (a)  C k (b) and P i  P k where “  “ denotes a relation that totally orders the processes n is there a single total order for a particular partial order? How many computations can be produced? How are these computations related? The happened before relationship “  ” defines a partial order among events: concurrent events cannot be ordered P1P1 e11 (1) e12 (2) P2P2 e21 (1) e22 (3)

Limitation of Scalar Clocks n scalar clocks are consistent but not strongly consistent: if a  b, then C(a)  C(b) but C(a)  C(b), then not necessarily a  b n example C(e11) < C(e22), and e11  e22 is true C(e11) < C(e32), but e11  e32 is false n from timestamps alone cannot determine whether two events are causally related P1P1 e11 (1) e12 (2) P2P2 e21 (1) e22 (3) P3P3 e31 (1) e32 (2) e33 (3)

Vector Clocks n independently developed by Fidge, Mattern and Schuck in 1988 assume system contains n processes each process P i maintains a vector vt i [1..n] vt i [i] entry is P i ’s own clock vt i [k], (where k  i ), is P i ’s estimate of the logical clock at P k  more specifically, the time of the occurrence of the last event in P k which “happened before” the current event in P i based on messages received

Vector Clocks Basic Implementation R1: before executing local event P i update its own clock C i as follows: vt i [i] := vt i [i] + d (d>0) if d=1, then vt i [i] is the number of events that causally precede current event. n R2: attach the whole vector to each outgoing message; when message received, update vector clock as follows vt i [k] := max(vt i [k], vt msg [k]) for 1≤ k ≤ n vt i [i] := max k (vt i [k]) execute R1 n comparing vector timestamps given two timestamps vh and vk vh ≤ vk if  x: vh[x] ≤ vk[x] vh < vk if vh ≤ vk and  x : vh[x] < vk[x] vh II vk if not vh ≤ vk and not vk ≤ vh n vector clocks are strongly consistent

Vector Clock Example n “enn” is event; “(n,n,n)” is clock value P1P1 e11 (1,0,0) e12 (2,0,0) P2P2 e21 (0,1,0) P3P3 e22 (2,2,0) e31 (0,0,1) e32 (0,0,2) e23 (2,3,1) e24 (2,4,1) e13 (3,4,1)

Singhal-Kshemkalyani’s Implementation of VC straightforward implementation of VCs is not scalable wrt system size because each message has to carry n integers n observation: instead of the whole vector only need to send elements that changed format: (id1, new counter1), (id2, new counter2), … decreases the message size if communication is localized problem: direct implementation – each process has to store latest VC sent to each receiver – O(N 2 ) S-K solution: maintain two vectors  LS[1..n] – “last sent”: LS[j] contains vt i [i] in the state, P i sent message to P j last  LU[1..n] – “last received”: LU[j] contains vt i [i] in the state, P i last updated vt i [j] essentially, P i “timestamps” each update and each message sent with its own counter  needs to send only {(x,vt i [x])| LS i [j] < LU i [x]}

Singhal-Kshemkalyani’s VC example when P 3 needs to send a message to P 2 (state 1), it only needs to send entries for P 3 and P 5

Application of VCs n causal ordering of messages maintaining the same causal order of message receive events as message sent that is: if Send (M1)  Send(M2) and Receive(M1) and Receive (M2) than Deliver(M1)  Deliver(M2) example above shows violation do not confuse with causal ordering of events n causal ordering is useful, for example in replicated databases or distributed state recording n two algorithms using VC Birman-Schiper-Stephenson (BSS) causal ordering of broadcasts Schiper-Eggli-Sandoz (SES) causal ordering of regular messages n basic idea – use VC to delay delivery of messages received out-of-order

Birman-Schiper-Stephenson (BSS) causal ordering of broadcasts n non-FIFO channels allowed each process P i maintains vector time vt i to track the order of broadcasts before broadcasting message m, P i increments vt i [i] and appends vt i to m (denoted vtm ) only sends are timestamped notice that ( vt i [i]-1 ) is the number of messages from P i preceding m when P j receives m from P i  P j it delivers it only when vt j [i] = vtm[i]-1 all previous messages from P i are received by P j vt j [k]  vtm[k],  k  {1,2,…n} but i  P j received all messages received by P i before sending m undelivered messages are stored for later delivery after delivery of m, vt j [k] is updated according to VC rule R2 on the basis of vtm and delayed messages are reevaluated

Schiper-Eggli-Sandoz (SES) Causal Ordering of Single Messages n non-FIFO channels allowed each process P i maintains V Pi – a set of entries (P,t) where P a destination process and t is a VC timestamp sending a message m from P 1 to P 2 send a message with a current timestamp t P1 and V P1 from P 1 to P 2 add (P 2, t P1 ) to V P1 -- for future messages to carry n receiving this message message can be delivered if  V m does not contain an entry for P 2  V m contains entry (P 2,t) but t  t P2 (where t P2 is current VC at P 2 ) after delivery  insert entries from V m into V P2 for every process P 3  P 3 if they are not there  update the timestamp of corresponding entry in V P2 otherwise  update VC of P 2 F deliver buffered messages if possible

Example Computations of BSS and SES

Matrix Clocks maintain an n  n matrix mt i at each process P i n interpretation mt i [i,i] - local event counter mt i [i,j] – latest info at P i about counter of P j. Note that row mt i [i,*] is a vector clock of P i mt i [j,k] – latest knowledge at P i about what P j knows of counter of P k update rules R1: before executing local event P i update its own clock C i as follows: mt i [i,i] := mt i [i,i] + d (d>0) R2: attach the whole matrix to each outgoing message, when message received from P j update matrix clock as follows mt i [i,k] := max(mt i [i,k], mt msg [i,j]) for 1≤ k ≤ n – synchronize vector clocks of P i and P j mt i [i,i] := max k (mt i [i,k]) – synchronize local counter mt i [k,l] := max(mt i [k,l], mt msg [k,l]) for 1≤ k,l ≤ n – update the rest of info execute R1 basic property: if min k (mt i [k,i])>t then  k mt k [k,i] >t that is, P i knows that the counter of each process P k progressed past k useful to delete obsolete info

Example Computation of Matrix Clocks