Synchronization Clock Synchronization Logical Clocks Global State Election Algorithms Mutual Exclusion.

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.
1 Chapter 3. Synchronization. STEMPusan National University STEM-PNU 2 Synchronization in Distributed Systems Synchronization in a single machine Same.
Distributed Computing
Tanenbaum & Van Steen, Distributed Systems: Principles and Paradigms, 2e, (c) 2007 Prentice-Hall, Inc. All rights reserved DISTRIBUTED.
Distributed Systems Spring 2009
Computer Science Lecture 12, page 1 CS677: Distributed OS Last Class Distributed Snapshots –Termination detection Election algorithms –Bully –Ring.
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.
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,
Synchronization in Distributed Systems CS-4513 D-term Synchronization in Distributed Systems CS-4513 Distributed Computing Systems (Slides include.
EEC-681/781 Distributed Computing Systems Lecture 11 Wenbing Zhao Cleveland State University.
EEC-681/781 Distributed Computing Systems Lecture 11 Wenbing Zhao Cleveland State University.
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.
Synchronization Chapter 5. Clock Synchronization When each machine has its own clock, an event that occurred after another event may nevertheless be assigned.
Computer Science Lecture 12, page 1 CS677: Distributed OS Last Class Vector timestamps Global state –Distributed Snapshot Election algorithms.
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.
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,
Tanenbaum & Van Steen, Distributed Systems: Principles and Paradigms, 2e, (c) 2007 Prentice-Hall, Inc. All rights reserved Chapter 6 Synchronization.
OS2- Sem , R. Jalili Synchronization Chapter 5.
Computer Science Lecture 10, page 1 CS677: Distributed OS Last Class: Naming Name distribution: use hierarchies DNS X.500 and LDAP.
Computer Science Lecture 12, page 1 CS677: Distributed OS Last Class Vector timestamps Global state –Distributed Snapshot Election algorithms –Bully algorithm.
1 Mutual Exclusion: A Centralized Algorithm a)Process 1 asks the coordinator for permission to enter a critical region. Permission is granted b)Process.
Synchronization CSCI 4900/6900. Importance of Clocks & Synchronization Avoiding simultaneous access of resources –Cooperate to grant exclusive access.
Global State (1) a)A consistent cut b)An inconsistent cut.
Synchronization CSCI 4780/6780. Mutual Exclusion Concurrency and collaboration are fundamental to distributed systems Simultaneous access to resources.
Tanenbaum & Van Steen, Distributed Systems: Principles and Paradigms, 2e, (c) 2007 Prentice-Hall, Inc. All rights reserved DISTRIBUTED SYSTEMS.
Fall 2007cs4251 Distributed Computing Umar Kalim Dept. of Communication Systems Engineering 15/01/2008.
Synchronization. Why we need synchronization? It is important that multiple processes do not access shared resources simultaneously. Synchronization in.
Synchronization Chapter 5. Outline 1.Clock synchronization 2.Logical clocks 3.Global state 4.Election algorithms 5.Mutual exclusion 6.Distributed transactions.
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?
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.
Synchronization Chapter 5. Table of Contents Clock Synchronization Logical Clocks Global State Election Algorithms Mutual Exclusion.
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
Tanenbaum & Van Steen, Distributed Systems: Principles and Paradigms, 2e, (c) 2007 Prentice-Hall, Inc. All rights reserved DISTRIBUTED SYSTEMS.
Clock Synchronization When each machine has its own clock, an event that occurred after another event may nevertheless be assigned an earlier time.
Election Distributed Systems. Algorithms to Find Global States Why? To check a particular property exist or not in distributed system –(Distributed) garbage.
Tanenbaum & Van Steen, Distributed Systems: Principles and Paradigms, 2e, (c) 2007 Prentice-Hall, Inc. All rights reserved DISTRIBUTED SYSTEMS.
Page 1 Mutual Exclusion & Election Algorithms Paul Krzyzanowski Distributed Systems Except as otherwise noted, the content.
6 SYNCHRONIZATION. introduction processes synchronize –exclusive access. –agree on the ordering of events much more difficult compared to synchronization.
Synchronization. Clock Synchronization In a centralized system time is unambiguous. In a distributed system agreement on time is not obvious. When each.
Synchronization Chapter 5. Clock Synchronization When each machine has its own clock, an event that occurred after another event may nevertheless be assigned.
COMP 655: Distributed/Operating Systems Summer 2011 Dr. Chunbo Chu Week 6: Synchronyzation 3/5/20161 Distributed Systems - COMP 655.
Distributed Mutual Exclusion Synchronization in Distributed Systems Synchronization in distributed systems are often 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.
Mutual Exclusion Algorithms. Topics r Defining mutual exclusion r A centralized approach r A distributed approach r An approach assuming an organization.
Lecture on Synchronization Submitted by
Synchronization in Distributed Systems In a single CPU system, critical regions, mutual exclusion and other synchronization problems are generally solved.
Prof. Leonardo Mostarda University of Camerino
Distributed Computing
CSC 8320 Advanced Operating Systems Spring 2006
DISTRIBUTED SYSTEMS Principles and Paradigms Second Edition ANDREW S
Chapter 5 (through section 5.4)
Prof. Leonardo Mostarda University of Camerino
Chap 5 Distributed Coordination
Last Class: Naming Name distribution: use hierarchies DNS
Outline Theoretical Foundations
Presentation transcript:

Synchronization Clock Synchronization Logical Clocks Global State Election Algorithms Mutual Exclusion

Learning outcomes By the end of this session, you should be able to: –Explain why synchronization is so important in distributed systems by giving an appropriate example –Describe a clock synchronization algorithm –Know what is the logical clock and describe an algorithm that can be used to synchronize the logical clocks. –Understand the concept of global state of a distributed system. –Know what’s the election algorithms for –Give an example of how mutual exclusion can be implemented in distributed systems.

1.Clock Synchronization In a centralized system, time is unambiguous. If process A asks for the time, and then a little later process B asks for the time, the value that B gets will be higher than the value A got. make example: make program compares the times at which all the sources and object files were last modified. If the source file is created late than its object file, compilation of that source file is deeded to create a new object file, vice versa, no recompilation needed. If the make program run on distributed systems without global agreement on time, there is a problem.

Clock Synchronization When each machine has its own clock, an event that occurred after another event may nevertheless be assigned an earlier time.

1.1 Physical Clocks Every computer has a circuit for keeping track of time, we call it ‘clock’ or ‘timer’ Although the frequency at which a crystal oscillator runs is usually fairly stable, it is impossible to guarantee that the crystals in different computers all run at exactly the same frequency. There are different ways to measure the time. E.g. mean solar time, International Atomic Time. There are also different organizations to broadcast the Universal Coordinated Time (UTC), e.g. NIST operates a shortwave radio station with call letters WWV to broadcast a short pulse at the start of each UTC second.

1.2 Clock Synchronization Algorithms All the algorithms have the same underlying model of the system, which will be describe bellow: –When UTC time is t, the value of the clock on machine p is Cp(t). In a perfect world, we would have Cp(t) = t for all p and all t, that is dC/dt=1. –Real timer do not interupt exactly H times a second as supposed. There must be a relative error. If there exists some constant c such that : 1-c < dC/dt < 1+c –That constant c is specified by the manufacturer and is known as the maximum drift rate –If two clocks are drifting from UTC in opposite direction, at a time Dt after they synchronized, they may be as much as 2c Dt apart. If the system designers want to guarantee that no two clocks ever differ by more than d, clock must be resynchronized (in software) at least every d /2c seconds

Clock Synchronization Algorithms The relation between clock time and UTC when clocks tick at different rates.

Cristian's Algorithm Getting the current time from a time server. –Sender set it time to C UTC after get reply from server, there are two problems for this algorithm: Major one is that time must never run backward. Change can be introduce gradually Minor one is that there it takes a nonzero amount of time for the timer server’s reply to get back to the sender.

The Berkeley Algorithm The time daemon asks all the other machines for their clock values The machines answer The time daemon tells everyone how to adjust their clock

2 Logical Clocks For many purposes, it is sufficient that all machines agree on the same time. It is not essential that this time also agree with the real time (e.g. UTC). It is conventional to speak of the clock as logical clocks. Lamport timestamps –The expression a->b is read “a happens before b” –The happens-before relation can be observed directly in two situations: 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.

Lamport Timestamps Three processes, each with its own clock. The clocks run at different rates. Lamport's algorithm corrects the clocks.

Lamport timestamps Happens-before is a transitive relation, so if a->b and b- >c, then a->c. If two events, x and y, happen in different processes that do not exchange messages, then x->y is not true, but neither is y->x. These event are said to be concurrent. Clock time C, must always go forward (increasing), never backward (decreasing) Use Lamport’s algorithm, we should assign time to all events in a distributed system subject to the following conditions: –If a happens before b in the same process, C(a)<C(b) –If a and b represent the sending and receiving of a message, respectively, C(a)<C(b). –For all distinctive events a and b, C(a)≠C(b).

Example: Totally-Ordered Multicasting Updating a replicated database and leaving it in an inconsistent state.

3. Global State The global state of a distributed system consists of the local state of each process, together with the messages that are currently in transit, that is, that have been sent but not delivered. Global state can be used to analysis if the distributed system in deadlock or distributed computation terminated One way to record the global state of a distributed system is to use the distributed snapshoot. It reflects a state in which the distributed system might have been. An important property is that such a snapshot reflects a consistent global state. The notion of a global state can be graphically represented by what is called a cut.

Global State A consistent cut An inconsistent cut

4. Election Algorithms Distributed algorithms usually require one process to act as coordinator, initiator, or otherwise perform some special role. The election algorithms are used for electing a coordinator. The goal of an election algorithm is to ensure that when an election starts, it concludes with all processes agreeing on who the new coordinator is to be. The Bully Algorithm: –When any process notices that the coordinator is no longer responding to requests, it initiates an election. A process, p, holds and election as follows: P sends an ELECTION message to all processes with higher numbers. If no one responds, P wins the election and becomes coordinator If one of the higher-ups answers, it takes over. P’s job is done.

The Bully Algorithm (1) The bully election algorithm Process 4 holds an election Process 5 and 6 respond, telling 4 to stop Now 5 and 6 each hold an election

The Bully Algorithm (2) Process 6 tells 5 to stop Process 6 wins and tells everyone

A Ring Algorithm Election algorithm using a ring.

Mutual Exclusion: A Centralized Algorithm Process 1 asks the coordinator for permission to enter a critical region. Permission is granted Process 2 then asks permission to enter the same critical region. The coordinator does not reply. When process 1 exits the critical region, it tells the coordinator, when then replies to 2

A Distributed Algorithm The process that want to enter a critical region builds a message containing the name of the critical region it wants to enter, its process number, and the current time. Send the message to all other processes and itself. For the process receives a request message, it will act in three different ways: –If the receiver is not in the critical region and does not want to enter it, it sends back an OK message to the sender. –If the receiver is already in the critical region, it does not reply. Instead, it queues the request. –If the receiver wants to enter the critical region but has not yet done so, it compares the timestamp in the incoming message with the one contained in the message that it has sent everyone. The lowest one wins. If the incoming message is lower, the receiver sends back an OK message. If its own message has a lower timestamp, the receiver queues the incoming request and sends nothing.

A Distributed Algorithm Two processes want to enter the same critical region at the same moment. Process 0 has the lowest timestamp, so it wins. When process 0 is done, it sends an OK also, so 2 can now enter the critical region.

A Toke Ring Algorithm An unordered group of processes on a network. A logical ring constructed in software.

Comparison A comparison of three mutual exclusion algorithms. Algorithm Messages per entry/exit Delay before entry (in message times) Problems Centralized32Coordinator crash Distributed2 ( n – 1 ) Crash of any process Token ring 1 to  0 to n – 1 Lost token, process crash