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.

Slides:



Advertisements
Similar presentations
Token-Dased DMX Algorithms n LeLann’s token ring n Suzuki-Kasami’s broadcast n Raymond’s tree.
Advertisements

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.
Tanenbaum & Van Steen, Distributed Systems: Principles and Paradigms, 2e, (c) 2007 Prentice-Hall, Inc. All rights reserved DISTRIBUTED.
Distributed Systems Spring 2009
CS 582 / CMPE 481 Distributed Systems
Ordering and Consistent Cuts Presented By Biswanath Panda.
Lecture 13 Synchronization (cont). EECE 411: Design of Distributed Software Applications Logistics Last quiz Max: 69 / Median: 52 / Min: 24 In a box outside.
EEC-681/781 Distributed Computing Systems Lecture 10 Wenbing Zhao Cleveland State University.
Hwajung Lee. Question 1. Why is physical clock synchronization important? Question 2. With the price of atomic clocks or GPS coming down, should we care.
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.
Distributed Systems Foundations Lecture 1. Main Characteristics of Distributed Systems Independent processors, sites, processes Message passing No shared.
1 Synchronization Part 1 REK’s adaptation of Claypool’s adaptation of Tanenbaum’s Distributed Systems Chapter 5.
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.
Tanenbaum & Van Steen, Distributed Systems: Principles and Paradigms, 2e, (c) 2007 Prentice-Hall, Inc. All rights reserved DISTRIBUTED SYSTEMS.
Distributed Mutual Exclusion
Computer Science Lecture 10, page 1 CS677: Distributed OS Last Class: Naming Name distribution: use hierarchies DNS X.500 and LDAP.
Parallel and Distributed Simulation Synchronizing Wallclock Time.
UBI529 Distributed Algorithms 2. Time Synchronization in Distributed Systems.
Communication & Synchronization Why do processes communicate in DS? –To exchange messages –To synchronize processes Why do processes synchronize in DS?
Distributed Systems Principles and Paradigms Chapter 05 Synchronization.
Hwajung Lee. Question 1. Why is physical clock synchronization important? Question 2. With the price of atomic clocks or GPS coming down, should we care.
Time This powerpoint presentation has been adapted from: 1) sApr20.ppt.
Tanenbaum & Van Steen, Distributed Systems: Principles and Paradigms, 2e, (c) 2007 Prentice-Hall, Inc. All rights reserved DISTRIBUTED SYSTEMS.
Real-Time & MultiMedia Lab Synchronization Distributed System Jin-Seung,KIM.
D u k e S y s t e m s Asynchronous Replicated State Machines (Causal Multicast and All That) Jeff Chase Duke University.
Physical clock synchronization Question 1. Why is physical clock synchronization important? Question 2. With the price of atomic clocks or GPS coming down,
ITEC452 Distributed Computing Lecture 6 Mutual Exclusion Hwajung Lee.
DISTRIBUTED SYSTEMS Principles and Paradigms Second Edition ANDREW S
Hwajung Lee. Mutual Exclusion CS p0 p1 p2 p3 Some applications are:  Resource sharing  Avoiding concurrent update on shared data  Controlling the.
Hwajung Lee. Mutual Exclusion CS p0 p1 p2 p3 Some applications are: 1. Resource sharing 2. Avoiding concurrent update on shared data 3. Controlling the.
Distributed Systems Topic 5: Time, Coordination and Agreement
Tanenbaum & Van Steen, Distributed Systems: Principles and Paradigms, 2e, (c) 2007 Prentice-Hall, Inc. All rights reserved DISTRIBUTED SYSTEMS.
6 SYNCHRONIZATION. introduction processes synchronize –exclusive access. –agree on the ordering of events much more difficult compared to synchronization.
Hwajung Lee. Primary standard = rotation of earth De facto primary standard = atomic clock (1 atomic second = 9,192,631,770 orbital transitions of Cesium.
Lecture 12-1 Computer Science 425 Distributed Systems CS 425 / CSE 424 / ECE 428 Fall 2012 Indranil Gupta (Indy) October 4, 2012 Lecture 12 Mutual Exclusion.
Lecture 7- 1 CS 425/ECE 428/CSE424 Distributed Systems (Fall 2009) Lecture 7 Distributed Mutual Exclusion Section 12.2 Klara Nahrstedt.
Decentralized solution 1
CIS 825 Review session. P1: Assume that processes are arranged in a ring topology. Consider the following modification of the Lamport’s mutual exclusion.
Mutual Exclusion Algorithms. Topics r Defining mutual exclusion r A centralized approach r A distributed approach r An approach assuming an organization.
Hwajung Lee. Mutual Exclusion CS p0 p1 p2 p3 Some applications are:  Resource sharing  Avoiding concurrent update on shared data  Controlling the.
CS3771 Today: Distributed Coordination  Previous class: Distributed File Systems Issues: Naming Strategies: Absolute Names, Mount Points (logical connection.
Proof of liveness: an example
Distributed Computing
Time and Clock Primary standard = rotation of earth
Distributed Mutex EE324 Lecture 11.
Time and Clock Primary standard = rotation of earth
Time and Clock.
Logical time (Lamport)
Time and Clock.
Decentralized solution 1
Mutual Exclusion Problem Specifications
ITEC452 Distributed Computing Lecture 7 Mutual Exclusion
Mutual Exclusion CS p0 CS p1 p2 CS CS p3.
ITEC452 Distributed Computing Lecture 10 Time in a Distributed System
Chapter 5 (through section 5.4)
Physical clock synchronization
CDK: Sections 11.1 – 11.4 TVS: Sections 6.1 – 6.2
ITEC452 Distributed Computing Lecture 7 Mutual Exclusion
Logical time (Lamport)
Logical time (Lamport)
Logical time (Lamport)
Proof of liveness: an example
Hwajung Lee ITEC452 Distributed Computing Lecture 6 Mutual Exclusion Sequential and concurrent events. Understanding logical clocks and vector clocks.
Last Class: Naming Name distribution: use hierarchies DNS
Presentation transcript:

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 133 atom atomic sec = 1 solar day – 3 ms (requires leap second correction each year) Coordinated Universal Time (UTC) = GMT ± number of hours in your time zone

Global positioning system: GPS A system of 32 satellites broadcast accurate spatial corordinates and time maintained by atomic clocks Location and precise time computed by triangulation Right now GPS time is nearly 14 seconds ahead of UTC, since It does not use leap sec. correction Per the theory of relativity, an additional correction is needed. Locally compensated by the receivers.

What does “concurrent” mean? Simultaneous? Happening at the same time? NO. There is nothing called simultaneous in the physical world. Alice Bob Explosion 1 Explosion 2

Physical clock synchronization Question 1. Why is physical clock synchronization important? Question 2. With the price of atomic clocks or GPS coming down, should we care about physical clock synchronization?

Classification Types of Synchronization  External Synchronization  Internal Synchronization  Phase Synchronization Types of clocks Unbounded 0, 1, 2, 3,... Bounded 0,1, 2,... M-1, 0, 1,... Unbounded clocks are not realistic, but are easier to deal with in the design of algorithms. Real clocks are always bounded.

Terminologies What are these? Drift rate  Clock skew  Resynchronization interval R Max drift rate  implies: (1-  ) ≤ dC/dt < (1+  ) Challenges (Drift is unavoidable) Accounting for propagation delay Accounting for processing delay Faulty clocks

Internal synchronization Berkeley Algorithm A simple averaging algorithm that guarantees mutual consistency |c(i) - c(j)| <  Step 1. Read every clock in the system. Step 2. Discard outliers and substitute them by the value of the local clock. Step 3. Update the clock using the average of these values. Resynchronization interval will depend on the drift rate.

Internal synchronization Lamport and Melliar-Smith’s averaging algorithm handles byzantine clocks too Assume n clocks, at most t are faulty Step 1. Read every clock in the system. Step 2. Discard outliers and substitute them by the value of the local clock. Step 3. Update the clock using the average of these values. Synchronization is maintained if n > 3t Why? A faulty clocks exhibits 2-faced or byzantine behavior Bad clock

Internal synchronization Lamport & Melliar-Smith’s algorithm (continued) The maximum difference between the averages computed by two non-faulty nodes is ( 3t  / n) To keep the clocks synchronized, 3t  / n <  So, 3t < n B a d c l o c k s k

Cristian’s method Client pulls data from a time server every R unit of time, where R <  / 2 . (why?) For accuracy, clients must compute the round trip time (RTT), and compensate for this delay while adjusting their own clocks. (Too large RTT’s are rejected) Time server External Synchronization

Network Time Protocol (NTP) Tiered architecture Broadcast mode - least accurate Procedure call - medium accuracy Peer-to-peer mode - upper level servers use this for max accuracy Time server The tree can reconfigure itself if some node fails. Level 1 Level 0 Level 2

P2P mode of NTP Let Q’s time be ahead of P’s time by . Then T2 = T1 + T PQ +  T4 = T3 + T QP -  y = T PQ + T QP = T2 +T4 -T1 -T3 (RTT)  = (T2 -T4 -T1 +T3) / 2 - (T PQ - T QP ) / 2 So, x- y/2 ≤  ≤ x+ y/2 T2 T1T4 T3 Q P Ping several times, and obtain the smallest value of y. Use it to calculate  x Between y/2 and -y/2

Problems with Clock adjustment 1. What problems can occur when a clock value is advanced from 171 to 174? 2. What problems can occur when a clock value is moved back from 180 to 175?

Sequential and Concurrent events Sequential = Totally ordered in time. Total ordering is feasible in a single process that has only one clock. This is not true in a distributed system. Two issues are important here:  How to synchronize physical clocks ? (We already discussed this)  Can we define sequential and concurrent events without using physical clocks, since physical clocks cannot be perfectly synchronized ?

Causality Causality helps identify sequential and concurrent events without using physical clocks. Joke  Re: joke (  implies causally ordered before or happened before) Message sent  message received Local ordering: a  b  c (based on the local clock)

Defining causal relationship Rule 1. If a, b are two events in a single process P, and the time of a is less than the time of b then a  b. Rule 2. If a = sending a message, and b = receipt of that message, then a  b. Rule 3. a  b  b  c  a  c

Example of causality a  d since(a  b  b  c  c  d) e  dsince(e  f  f  d) (Note that  defines a PARTIAL order). Is g  f or f  g? NO.They are concurrent.. Concurrency = absence of causal order

Logical clocks LC is a counter. Its value respects causal ordering as follows a  b  LC(a) < LC(b) Note that LC(a) < LC(b) does NOT imply a  b. Each process maintains its logical clock as follows: LC1. Each time a local event takes place, increment LC. LC2. Append the value of LC to outgoing messages. LC3. When receiving a message, set LC to 1 + max ( local LC, message LC )

Total order in a distributed system Total order is important for some applications like scheduling (first- come first served). But total order does not exist! What can we do? Strengthen the causal order  to define a total order (<<) among events. Use LC to define total order (in case two LC’s are equal, process id’s will be used to break the tie). Let a, b be events in processes i and j respectively. Then a << b iff -- LC(a) < LC(b) OR -- LC(a) = LC(b) and i < j a  b  a << b, but the converse is not true. The value of LC of an event is called its timestamp.

Vector clock Causality detection can be an important issue in applications like group communication. Logical clocks do not detect causal ordering. Vector clocks do. a  b  VC(a) < VC(b) C may receive Re:joke before joke, which is bad!

Implementing VC {Sender process i} 1. Increment VC[i]. 2. Append the local VC to every outgoing message. {Receiver process j} 3. When a message with a vector timestamp T arrives from i, first increment the j th component VC[j] of the local vector clock, and then update the local vector clock as follows:  k: 0 ≤ k ≤N-1:: VC[k] := max (T[k], VC[k]). i th component of VC

Vector clocks Example [3, 3, 4, 5, 3, 2, 1, 4] < [3, 3, 4, 5, 3, 2, 2, 5] But, [3, 3, 4, 5, 3, 2, 1, 4] and [3, 3, 4, 5, 3, 2, 2, 3] are not comparable Let a, b be two events. Define. VC(a) < VC(b) iff  i : 0 ≤ i ≤ N-1 : VC(a)[i] ≤ VC(b)[i], and  j : 0 ≤ j ≤ N-1 : VC(a)[j] < VC(b)[j], VC(a) < VC(b)  a  b Causality detection

Mutual Exclusion CS p0 p1 p2 p3

Why mutual exclusion? Some applications are: 1.Resource sharing 2.Avoiding concurrent update on shared data 3.Controlling the grain of atomicity 4.Medium Access Control in Ethernet 5.Collision avoidance in wireless broadcasts

Specifications ME1. At most one process in the CS. (Safety property) ME2. No deadlock. (Safety property) ME3. Every process trying to enter its CS must eventually succeed. This is called progress. (Liveness property) Progress is quantified by the criterion of bounded waiting. It measures a form of fairness by answering the question: Between two consecutive CS trips by one process, how many times other processes can enter the CS? There are many solutions, both on the shared memory model and the message-passing model

Message passing solution: Centralized decision making clients Client do true  send request; wait until a reply is received; enter critical section (CS) send release; od Server do request received and not busy  send reply; busy:= true request received and busy  enqueue sender release received and queue is empty  busy:= false release received and queue not empty  send reply to the head of the queue od busy: boolean server queue req reply release

Comments -Centralized solution is simple. -But the server is a single point of failure. This is BAD. -ME1-ME3 is satisfied, but FIFO fairness is not guaranteed. Why? Can we do better? Yes!

Decentralized solution 1: Lamport’s algorithm { Life of each process } 1. Broadcast a timestamped request to all. 2. Reques t received  enqueue sender in local Q;. Not in CS  send ack In CS  postpone sending ack (until exit from CS). 3. Enter CS, when (i) You are at the head of your own local Q (ii) You have received ack from all processes 4. To exit from the CS, (i) Delete the request from Q, and (ii) Broadcast a timestamped release 5. Release received  remove sender from local Q. Completely connected topology Can you show that it satisfies all the properties (i.e. ME1, ME2, ME3) of a correct solution ?