EEC-681/781 Distributed Computing Systems Lecture 10 Wenbing Zhao Cleveland State University.

Slides:



Advertisements
Similar presentations
Synchronization.
Advertisements

Time and synchronization (“There’s never enough time…”)
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.
Tanenbaum & Van Steen, Distributed Systems: Principles and Paradigms, 2e, (c) 2007 Prentice-Hall, Inc. All rights reserved DISTRIBUTED.
Distributed Systems Spring 2009
1. Explain why synchronization is so important in distributed systems by giving an appropriate example When each machine has its own clock, an event that.
EEC 688/788 Secure and Dependable Computing Lecture 12 Wenbing Zhao Department of Electrical and Computer Engineering Cleveland State University
Synchronization Clock Synchronization Logical Clocks Global State Election Algorithms Mutual Exclusion.
© Chinese University, CSE Dept. Distributed Systems / Distributed Systems Topic 9: Time, Coordination and Replication Dr. Michael R. Lyu Computer.
Distributed Systems CS Synchronization – Part II Lecture 8, Sep 28, 2011 Majd F. Sakr, Vinay Kolar, Mohammad Hammoud.
EEC 693/793 Special Topics in Electrical Engineering Secure and Dependable Computing Lecture 13 Wenbing Zhao Department of Electrical and Computer Engineering.
Synchronization in Distributed Systems. Mutual Exclusion To read or update shared data, a process should enter a critical region to ensure mutual exclusion.
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 688/788 Secure and Dependable Computing Lecture 13 Wenbing Zhao Department of Electrical and Computer Engineering Cleveland State University
EEC-681/781 Distributed Computing Systems Lecture 11 Wenbing Zhao Cleveland State University.
Time, Clocks and the Ordering of Events in a Distributed System - by Leslie Lamport.
1 CLOCK SYNCHRONIZATION " Synchronization in distributed systems is more complicated than in centralized ones because the former have to use distributed.
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.
EEC 693/793 Special Topics in Electrical Engineering Secure and Dependable Computing Lecture 13 Wenbing Zhao Department of Electrical and Computer Engineering.
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.
1 Synchronization Part 1 REK’s adaptation of Claypool’s adaptation of Tanenbaum’s Distributed Systems Chapter 5.
Synchronization Chapter 6 Part I Clock Synchronization & Logical clocks Part II Mutual Exclusion Part III Election Algorithms Part IV Transactions.
Lecture 2-1 CS 425/ECE 428 Distributed Systems Lecture 2 Time & Synchronization Reading: Klara Nahrstedt.
1 Physical Clocks need for time in distributed systems physical clocks and their problems synchronizing physical clocks u coordinated universal time (UTC)
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.
Naming CSCI 4780/6780. Attribute-based Naming Flat and structured names provide location transparency Structured names are also human-friendly Increasingly,
Computer Science Lecture 10, page 1 CS677: Distributed OS Last Class: Naming Name distribution: use hierarchies DNS X.500 and LDAP.
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.
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.
Lecture 9: Time and clocks (Chap 11) Haibin Zhu, PhD. Assistant Professor Department of Computer Science Nipissing University © 2002.
Time, Clocks, and the Ordering of Events in a Distributed System Leslie Lamport Massachusetts Computer Associates,Inc. Presented by Xiaofeng Xiao.
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.
Synchronization CSCI 4900/6900. Importance of Clocks & Synchronization Avoiding simultaneous access of resources –Cooperate to grant exclusive access.
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 CS Synchronization – Part I Lecture 8, Sep 23, 2013 Mohammad Hammoud.
Distributed Process Coordination Presentation 1 - Sept. 14th 2002 CSE Spring 02 Group A4:Chris Sun, Min Fang, Bryan Maden.
DISTRIBUTED SYSTEMS Principles and Paradigms Second Edition ANDREW S
Distributed Systems Topic 5: Time, Coordination and Agreement
CS 3471 CS 347: Parallel and Distributed Data Management Notes13: Time and Clocks.
Feb 15, 2001CSCI {4,6}900: Ubiquitous Computing1 Announcements.
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.
6 SYNCHRONIZATION. introduction processes synchronize –exclusive access. –agree on the ordering of events much more difficult compared to synchronization.
Synchronization Chapter 5. Clock Synchronization When each machine has its own clock, an event that occurred after another event may nevertheless be assigned.
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 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.
COMP 655: Distributed/Operating Systems Summer 2011 Dr. Chunbo Chu Week 6: Synchronyzation 3/5/20161 Distributed Systems - COMP 655.
Synchronization in Distributed Systems In a single CPU system, critical regions, mutual exclusion and other synchronization problems are generally solved.
11-Jun-16CSE 542: Operating Systems1 Distributed systems Time, clocks, and the ordering of events in a distributed system Leslie Lamport. Communications.
Prof. Leonardo Mostarda University of Camerino
Distributed Computing
Time and Clock.
Time and Clock.
EEC 688/788 Secure and Dependable Computing
EEC 688/788 Secure and Dependable Computing
Chapter 5 (through section 5.4)
EEC 688/788 Secure and Dependable Computing
EEC 688/788 Secure and Dependable Computing
CSE 542: Operating Systems
Last Class: Naming Name distribution: use hierarchies DNS
Outline Theoretical Foundations
Presentation transcript:

EEC-681/781 Distributed Computing Systems Lecture 10 Wenbing Zhao Cleveland State University

2 Fall Semester 2008EEC-681: Distributed Computing SystemsWenbing Zhao Outline Clock Synchronization issues Clock Synchronization Algorithms –Centralized –Distributed Event ordering and logical clocks

3 Fall Semester 2008EEC-681: Distributed Computing SystemsWenbing Zhao Motivation for Clock Synchronization In everyday life, we are relying on clocks to coordinate our activities –For example, in EEC681, we meet every Monday and Wednesday between 6-7:50pm In computer systems, it is also convenient to use clock as a way to coordinate different activities –For example, the “make” program relies on files’ timestamp to decide if a recompilation is necessary

4 Fall Semester 2008Wenbing Zhao Motivation for Clock Synchronization Stock market buy and sell orders Secure document timestamps (with cryptographic certification) Aviation traffic control and position reporting Radio and TV programming launch and monitoring Intruder detection, location and reporting Multimedia synchronization for real-time teleconferencing Network monitoring, measurement and control Differentiated services traffic engineering EEC-681: Distributed Computing Systems

5 Fall Semester 2008EEC-681: Distributed Computing SystemsWenbing Zhao Universal Coordinated Time Universal Coordinated Time (UTC): –Based on the number of transitions per second of the cesium 133 atom (pretty accurate) –At present, the real time is taken as the average of some 50 cesium-clocks around the world –Introduces a leap second from time to time to compensate that days are getting longer UTC is broadcast through short wave radio and satellite. –Satellites can give an accuracy of about 0.5 ms

6 Fall Semester 2008EEC-681: Distributed Computing SystemsWenbing Zhao Physical Clocks in Computer Systems Every machine has a timer that generates an interrupt H times per second There is a clock in machine p that ticks on each timer interrupt –Denote the value of that clock by C p (t), where t is UTC time –Ideally, for each machine p, C p (t) = t, or, in other words, dC/dt = 1

7 Fall Semester 2008EEC-681: Distributed Computing SystemsWenbing Zhao Clock Time and UTC The relation between clock time and UTC when clocks tick at different rates In practice: 1 -  < dC/dt < 1 +  Maximum drift rate:  Clock time, C

8 Fall Semester 2008EEC-681: Distributed Computing SystemsWenbing Zhao Terms Clock drift rate (or clock accuracy) –The amount of deviation from UTC per unit of time (a day or a week, etc.) Clock precision: –Resolution of the clock, e.g., 1  s, or 1ns Clock skew –The difference in time values of two clocks is called clock skew –Maximum clock skew of a group of clocks is determined by the two clocks that have the largest clock difference

9 Fall Semester 2008EEC-681: Distributed Computing SystemsWenbing Zhao Clock Synchronization Two clocks are said to be synchronized at a particular instance of time if the clock skew of the two clocks is less than some specified constant δ A set of clocks are said to be synchronized if the clock skew of any two clocks in this set is less than δ

10 Fall Semester 2008EEC-681: Distributed Computing SystemsWenbing Zhao Clock Synchronization Issues A distributed system requires: –External Synchronization Synchronize with an external time source –Internal Synchronization Clocks within the same network synchronize with each other Clock Synchronization requires: –Each node can read the other nodes’ clock values Must consider unpredicted communication delay –Time must never run backward Smooth adjustments => must maintain the order of the events

11 Fall Semester 2008EEC-681: Distributed Computing SystemsWenbing Zhao Message Propagation Time Estimate of message propagation time: (T 1 -T 0 -I)/2

12 Fall Semester 2008EEC-681: Distributed Computing SystemsWenbing Zhao Message Delay Distribution T1T1 T3T3 T2T2 T4T4 Server Client x 00

13 Fall Semester 2008EEC-681: Distributed Computing SystemsWenbing Zhao Clock Synchronization Algorithms Centralized –Passive Time Server Centralized Algorithm Cristian’s algorithm –Active Time Server Centralized Algorithm Berkeley Algorithm Distributed –Global Averaging Distributed Algorithms –Localized Averaging Distributed Algorithms

14 Fall Semester 2008EEC-681: Distributed Computing SystemsWenbing Zhao Passive Timer Server Each node periodically sends a message (time=?) to the time server at the current local clock time, T 0 The server responds with a message (time = T), T is the current time of the server The client receives the message at the local clock time T 1, and adjusts its local clock time to T+(T 1 -T 0 -I)/2 –The time taken by the server to handle the request message is I, T+(T 1 -T 0 -I)/2 –Several measurements of T 1 -T 0, discard the unreliable ones

15 Fall Semester 2008EEC-681: Distributed Computing SystemsWenbing Zhao Active Time Server The time server periodically broadcasts its clock time (T) Other nodes receive the message to correct their own clocks –Each node has the knowledge of the approximate time (T a ) required for the propagation of the message, T+T a –Each nodes replies with the local clock time The server –Knows the approximate propagation time from each node –Takes fault-tolerant average of clock values as current time –The server adjusts it own, and sends the amount by which each node clock requires adjustment to each node

16 Fall Semester 2008EEC-681: Distributed Computing SystemsWenbing Zhao Centralized Algorithms – Drawbacks Single-point failure Scalability

17 Fall Semester 2008EEC-681: Distributed Computing SystemsWenbing Zhao Global Averaging Distributed Algorithms Each node broadcasts its local clock time periodically Each node waits for time T –The node collects the messages broadcast by other nodes –For each message received, the node keeps the local time –At the end of T, the node estimates the skew of its clock with respect to each of the other nodes on the basis of the times at which it received –The node computes a fault-tolerant average of the estimated skews and uses it to adjust its local clock

18 Fall Semester 2008EEC-681: Distributed Computing SystemsWenbing Zhao Localized Averaging Distributed Algorithms Each node exchanges its clock time with its neighbors Then sets its clock time to the average of its own clock and the clock times of its neighbors

19 Fall Semester 2008EEC-681: Distributed Computing SystemsWenbing Zhao Exercise Consider the behavior of two machines in a distributed system. Both have clocks that are supposed to tick 1000 times per millisecond. One of them actually does, but the other ticks only 990 times per millisecond. If UTC updates come in once a minute, what is the maximum clock skew that will occur?

20 Fall Semester 2008EEC-681: Distributed Computing SystemsWenbing Zhao Event Ordering “Time, Clocks, and the Ordering of Events in a Distributed System”, by Leslie Lamport, Communications of the ACM, July 1978, Volume 21, Number 7, pp He showed that it is possible to synchronize all the clocks to produce a single, unambiguous time standard He pointed out the clock synchronization need not to be absolute –What usually matters is not that all processes agree on exactly what time it is, but rather, that they agree on the order in which events occur

21 Fall Semester 2008EEC-681: Distributed Computing SystemsWenbing Zhao Happens-before Relation With perfectly accurate physical time –An event a happened before an event b if a happened at an earlier time than b Without using the physical clocks –Assume that the system is composed of a collection of processes, each process consists of a sequence of events –The events of a process form a sequence, where a occurs before b in this sequence if a happens before b –Assume sending and receiving a message is an event in a process

22 Fall Semester 2008EEC-681: Distributed Computing SystemsWenbing Zhao Happens-before Relation “Happens-before” relation, denoted by “→”, is defined as follows: –The relation “→” on the set of events of a system is the relation satisfying the following three conditions: If a and b are events in the same process, and a comes before b, then a → b If a is the sending of a message by one process and b is the receipt of the same message by another process, then a → b If a → b and b → c, then a → c –Event a causally affects event b

23 Fall Semester 2008EEC-681: Distributed Computing SystemsWenbing Zhao Partial Ordering Two distinct events a and b are said to be concurrent if a → b and b → a –Neither event can causally affect the other –This introduces a partial ordering of events in a system with concurrently operating processes

24 Fall Semester 2008EEC-681: Distributed Computing SystemsWenbing Zhao Logical Clocks Logical clocks: Use the clock just as a way of assigning a number to an event, where the number is the time at which the event occurs –Define a clock C i for each process P i Assigns a number C i (a) to any event a in that process The entire system of clocks is represented by the function C which assigns to any event b the number C(b), where C(b) =C j (b) if b is an event in process P j The clocks C i are logical clocks rather than physical clocks

25 Fall Semester 2008EEC-681: Distributed Computing SystemsWenbing Zhao Implementation of Logical Clocks The logical clocks is correct if the events of the system that are related to each other by the happens-before relation can be properly ordered using these clocks Clock condition: –For any event a, b, if a  b then C(a) <C(b)

26 Fall Semester 2008EEC-681: Distributed Computing SystemsWenbing Zhao Implementation of Logical Clocks According to our definition of the happens- before relation, the clock condition is satisfied if the following two conditions hold: –C1: if a and b are events in process P i, and a comes before b, then C i (a) < C i (b) –C2: if a is the sending of a message by process P i and b is the receipt of that message by process P j, then C i (a) < C j (b)

27 Fall Semester 2008EEC-681: Distributed Computing SystemsWenbing Zhao Implementation of Logical Clock To meet C1: –Each process P i increments C i between any two successive events To meet C2: –(a) if event a is the sending of a message m by process P i, then the message m contains a timestamp T m = C i (a). –(b) Upon receiving a message m, process P j sets C j greater than or equal to its present value and greater than T m

28 Fall Semester 2008EEC-681: Distributed Computing SystemsWenbing Zhao Implementation of Logical Clocks by Counters A Lamport logical clock is a monotonically increasing software counter Each process P i keeps its own logical clock C i which is used to apply Lamport timestamps to events To capture the happens-before relation →, processes update their logical clocks and transmit the values of their logical clocks in messages as follows: –Before each event at P i : C i := C i +1 –When P i sends a message m, it piggybacks t = C i –When P j receives (m,t): C j := max(C j,t) + 1 e → e’ => C(e) < C(e’)

29 Fall Semester 2008EEC-681: Distributed Computing SystemsWenbing Zhao Implementation of Logical Clocks by Counters Question: Which two events are concurrent?

30 Fall Semester 2008EEC-681: Distributed Computing SystemsWenbing Zhao Total Ordering of Events We can use the logical clocks satisfying the Clock Condition to place a total ordering on the set of all system events –Simply order the events by the times at which occur –To break the ties, Lamport proposed the use of any arbitrary total ordering of the processes, i.e. process id

31 Fall Semester 2008EEC-681: Distributed Computing SystemsWenbing Zhao Total Ordering of Events Using this method, we can assign a unique timestamp to each event in a distributed system to provide a total ordering of all events Very useful in distributed system –Solving the mutual exclusion problem –Totally ordered reliable multicast => needed to build fault tolerant systems