6 SYNCHRONIZATION. introduction processes synchronize –exclusive access. –agree on the ordering of events much more difficult compared to synchronization.

Slides:



Advertisements
Similar presentations
Synchronization.
Advertisements

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.
Tanenbaum & Van Steen, Distributed Systems: Principles and Paradigms, 2e, (c) 2007 Prentice-Hall, Inc. All rights reserved DISTRIBUTED.
Time and Global States ECEN5053 Software Engineering of Distributed Systems University of Colorado, Boulder.
Distributed Systems Spring 2009
Distributed Systems Fall 2010 Time and synchronization.
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.
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.
Synchronization in Distributed Systems. Mutual Exclusion To read or update shared data, a process should enter a critical region to ensure mutual exclusion.
SynchronizationCS-4513, D-Term Synchronization in Distributed Systems CS-4513 D-Term 2007 (Slides include materials from Operating System Concepts,
Lecture 13 Synchronization (cont). EECE 411: Design of Distributed Software Applications Logistics Last quiz Max: 69 / Median: 52 / Min: 24 In a box outside.
Synchronization in Distributed Systems CS-4513 D-term Synchronization in Distributed Systems CS-4513 Distributed Computing Systems (Slides include.
1 CLOCK SYNCHRONIZATION " Synchronization in distributed systems is more complicated than in centralized ones because the former have to use distributed.
Clock Synchronization and algorithm
Tanenbaum & Van Steen, Distributed Systems: Principles and Paradigms, 2e, (c) 2007 Prentice-Hall, Inc. All rights reserved DISTRIBUTED SYSTEMS.
EEC-681/781 Distributed Computing Systems Lecture 10 Wenbing Zhao Cleveland State University.
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.
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.
Synchronization.
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)
ALGORITHMS FOR ISNE DR. KENNETH COSH WEEK 13.
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,
OS2- Sem , R. Jalili Synchronization Chapter 5.
Synchronization in Distributed Systems Chapter 6.
Computer Science Lecture 10, page 1 CS677: Distributed OS Last Class: Naming Name distribution: use hierarchies DNS X.500 and LDAP.
Synchronization CSCI 4900/6900. Importance of Clocks & Synchronization Avoiding simultaneous access of resources –Cooperate to grant exclusive access.
Tanenbaum & Van Steen, Distributed Systems: Principles and Paradigms, 2e, (c) 2007 Prentice-Hall, Inc. All rights reserved DISTRIBUTED SYSTEMS.
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.
Synchronization Chapter 5.
Tanenbaum & Van Steen, Distributed Systems: Principles and Paradigms, 2e, (c) 2007 Prentice-Hall, Inc. All rights reserved 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.
1 Clock Synchronization & Mutual Exclusion in Distributed Operating Systems Brett O’Neill CSE 8343 – Group A6.
Lecture 9: Time and clocks (Chap 11) Haibin Zhu, PhD. Assistant Professor Department of Computer Science Nipissing University © 2002.
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.
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.
Synchronization CSCI 4900/6900. Importance of Clocks & Synchronization Avoiding simultaneous access of resources –Cooperate to grant exclusive access.
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
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.
Synchronization. Clock Synchronization In a centralized system time is unambiguous. In a distributed system agreement on time is not obvious. When each.
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.
Distributed Systems CS
Prof. Leonardo Mostarda University of Camerino
Distributed Computing
CSC 8320 Advanced Operating Systems Spring 2006
Time Synchronization and Logical Clocks
DISTRIBUTED SYSTEMS Principles and Paradigms Second Edition ANDREW S
Distributed Systems CS
Chapter 5 (through section 5.4)
Distributed Synchronization
Last Class: Naming Name distribution: use hierarchies DNS
Outline Theoretical Foundations
Presentation transcript:

6 SYNCHRONIZATION

introduction processes synchronize –exclusive access. –agree on the ordering of events much more difficult compared to synchronization in uniprocessor or multiprocessor systems Synchronization –based on actual time –relative ordering matters –election algorithms

contents 6.1 CLOCK SYNCHRONIZATION 6.2 LOGICAL CLOCKS 6.3 MUTUAL EXCLUSION 6.4 GLOBAL POSITIONING OF NODES 6.5 ELECTION ALGORITHMS

6.1 CLOCK SYNCHRONIZATION Physical Clocks Global Positioning System Clock Synchronization Algorithms

problem In a centralized system, time is unambiguous In a distributed system, achieving agreement on time is not trivial e.g. make program

6.1.1 Physical Clocks Clock tick –A Counter and a holding register –Each oscillation of the crystal decrements the counter by one –When the counter gets to zero, an interrupt is generated and the counter is reloaded from the holding register –Each interrupt is called one clock tick With a single computer and a single clock, it does not matter much if this clock is off by a small amount –All that really matters are the relative times

Time clock skew –This difference in time values of different machines Seconds –solar second (mean) –atomic second TAI –UTC BIR solves the problem by introducing leap seconds whenever the discrepancy between TAI and solar time grows to 800 msec. UTC is the basis of all modern civil timekeeping

Leap second

Since 1 sec is a noticeable interval for a computer, an operating system that needs to keep accurate time over a period of years must have special software to account for leap seconds as they are announced

6.1.2 Global Positioning System A satellite continuously broadcasts its position and time stamps each message with its local time

determining positions two important real-world facts –It takes a while before data on a satellite's position reaches the recerver –The receiver's clock is generally not in synch with that of a satellite Errors –leap seconds –atomic clocks in the satellites are not always in perfect –the position of a satellite is not known precisely –the receiver's clock has a finite accuracy –the signal propagationspeed is not constant –the earth is not a perfect sphere

6.1.3 Clock Synchronization Algorithms the goal is to keep all the machines together as well as possible Each machine –timer that causes an interrupt H times a second –software clock –All C(U) = t, in a perfact world resynchronization If two clocks are drifting from UTC in the opposite direction, at a time dt after they were synchronized, they may be as much as 2p apart

Network time protocol The server can accurately provide the current time Offset of time –A send a request to B, timestamped with value T1 –B record the time of receipt T2 –B returns a response timestamped with value T 3, and piggybacking the previously recorded value T2 –A records the time of the response's arrival T4 –assumeT2-T1 =T4-T3, A can estimate its offset relative to B as theta, theta =((T2-T1)+(T3-T4))/2 Adjust time –Gradually –Time interrupt: time unit +/-

NTP--strata NTP divides servers into strata stratum 0 –the atomic clock itself stratum-1 –A server with a reference clock such as a WWV receiver or an atomic clock When A contacts B, it will only adjust its time if its own stratum level is higher than that of B

The Berkeley Algorithm In NTP, the time server is passive. Berkeley Algorithm –polling every machine –computes an average time –all the other machines to set their clocks to the new time no machine has a WWV receiver it is sufficient that all machines agree on the same time

The Berkeley Algorithm

Clock Synchronization in Wireless Networks in a sensor network the time to propagate a signal to other nodes is roughly constant –no multi-hop routing is assumed Reference broadcast synchronization (RBS) is a clock synchronization protocol –does not assume that there is a single node with an accurate time –it aims at merely internally synchronizing the clocks

The idea underlying RBS when a node broadcasts a message m each node p simply records the time Tp,m that it received m. two nodes p and q can exchange each other's delivery times in order to estimate their mutual, relative offset

Improvement Unfortunately, clocks can drift apart The effect is that simply computing the average offset as done above will not work

6.2 LOGICAL CLOCKS Lamport's Logical Clocks –it may be sufficient that every node agrees on a current time –Example: make Vector Clocks –with Lamport clocks, nothing can be said about C(a) < C(b), then this does not necessarily imply that a indeed happened before b

happens-before relation If a and b are events in the same process, and a occurs before b, then a ~ b is true. If a is the event of a message being sent by one process, and b is the event of the message being received by another process, then a ~ b is also true Happens-before is a transitive relation, so if a ~ band b ~ c, then a ~ c.

concurrent Iftwo events, x and y, happen in different processes that do not exchange messages (not even indirectly via third parties), then x ~ y is not true, but neither is y ~ x. These events are said to be concurrent, which simply means that nothing can be said (or need be said) about when the events happened or which event happened first

Lamport's algorithm corrects clocks

explanation Lamport's solution follows directly from the happens-before relation –Since m 3 left at 60, it must arrive at 61 or later When a message arrives and the receiver's clock shows a value prior to the time the message was sent, the receiver fast forwards its clock to be one more than the sending time

The positioning of logical clocks

Lamport's logical clocks each process Pi maintains a local counter G –executing an event –delivering a message to an application –some other internal event –Pi executes G = G + 1 When process Pi sends a message m to Pj, it sets timestamp ts (m) equal to G Upon the receipt of a message m, process Pj adjusts its own local counter as max{G, ts (m) }, after which it then executes the first step and delivers the message to the application

supplement In some situations, an additional requirement is desirable: no two events ever occur at exactly the same time. we can attach the number of the process in which the event occurs to the low-order end of the time, separated by a decimal point. For example, an event at time 40 at process Pi will be timestamped with 40.i.

Totally Ordered Multicasting Example

the same order The problem that we are faced with is that the two update operations should have been performed in the same order at each copy Although it makes a difference to execute in the two orders, the order is followed is not important from a consistency point of view The important issue is that both copies should be exactly the same.

totally-ordered multicast a multicast operation by which all messages are delivered in the same order to each receiver. Lamport's logical clocks can be used to implement totally-ordered multi casts in a completely distributed fashion

solution When a process receives a message, it is put into a local queue, ordered according to its timestamp. The receiver multicasts an acknowledgment to the other processes. Note that if we follow Lamport's algorithm for adjusting local clocks, the timestamp of the received message is lower than the timestamp of the acknowledgment. The interesting aspect of this approach is that all processes will eventually have the same copy of the local queue (provided no messages are removed).

6.3 MUTUAL EXCLUSION Overview A Centralized Algorithm A Decentralized Algorithm A Distributed Algorithm A Token Ring Algorithm A Comparison of the Four Algorithms

6.4 GLOBAL POSITIONING OF NODES

6.5 ELECTION ALGORITHMS Traditional Election Algorithms Elections in Wireless Environments Elections in Large-Scale Systems