Synchronization Chapter 5 5.1 clock synchronization * 5.2 logical clocks * 5.3 global state * 5.4 election algorithm * 5.5 mutual exclusion * 5.6 distributed.

Slides:



Advertisements
Similar presentations
Global States.
Advertisements

1 CS 194: Elections, Exclusion and Transactions Scott Shenker and Ion Stoica Computer Science Division Department of Electrical Engineering and Computer.
Time and Global States Part 3 ECEN5053 Software Engineering of Distributed Systems University of Colorado, Boulder.
Distributed Computing
Page 1 Mutual Exclusion* Distributed Systems *referred to slides by Prof. Paul Krzyzanowski at Rutgers University and Prof. Mary Ellen Weisskopf at University.
Tanenbaum & Van Steen, Distributed Systems: Principles and Paradigms, 2e, (c) 2007 Prentice-Hall, Inc. All rights reserved DISTRIBUTED.
Distributed Systems Spring 2009
4. Synchronization Clock synchronization
CS 582 / CMPE 481 Distributed Systems
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 Clock Synchronization Logical Clocks Global State Election Algorithms Mutual Exclusion.
Computer Science Lecture 11, page 1 CS677: Distributed OS Last Class: Clock Synchronization Logical clocks Vector clocks Global state.
Synchronization in Distributed Systems. Mutual Exclusion To read or update shared data, a process should enter a critical region to ensure mutual exclusion.
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.
Clock Synchronization and algorithm
Tanenbaum & Van Steen, Distributed Systems: Principles and Paradigms, 2e, (c) 2007 Prentice-Hall, Inc. All rights reserved DISTRIBUTED SYSTEMS.
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 10, page 1 CS677: Distributed OS Last Class: Clock Synchronization Physical clocks Clock synchronization algorithms –Cristian’s.
Computer Science Lecture 12, page 1 CS677: Distributed OS Last Class Vector timestamps Global state –Distributed Snapshot Election algorithms.
Time, Clocks, and the Ordering of Events in a Distributed System Leslie Lamport (1978) Presented by: Yoav Kantor.
Election Algorithms. Topics r Issues r Detecting Failures r Bully algorithm r Ring algorithm.
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.
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.
Distributed Mutex EE324 Lecture 11.
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.
Presenter: Long Ma Advisor: Dr. Zhang 4.5 DISTRIBUTED MUTUAL EXCLUSION.
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.
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.
Distributed Systems Fall 2010 Logical time, global states, and debugging.
Real-Time & MultiMedia Lab Synchronization Distributed System Jin-Seung,KIM.
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
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.
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.
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.
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
Distributed Systems Lecture 6 Global states and snapshots 1.
Distributed Mutex EE324 Lecture 11.
Distributed Systems CS
DISTRIBUTED SYSTEMS Principles and Paradigms Second Edition ANDREW S
Distributed Systems CS
Lecture 10: Coordination and Agreement
Chapter 5 (through section 5.4)
Prof. Leonardo Mostarda University of Camerino
Lecture 11: Coordination and Agreement
Presentation transcript:

Synchronization Chapter clock synchronization * 5.2 logical clocks * 5.3 global state * 5.4 election algorithm * 5.5 mutual exclusion * 5.6 distributed transaction

2 Issues Multiple processes do not simultaneously access a shared resource Multiple processes need to agree on the ordering of events Synchronization based on relative ordering How to record a distributed global state How to elect a coordinator among a group of processes Distributed mutual exclusion allows shared resources to be protected against simultaneous access by multiple processes Distributed transactions, in addition, optimize access through advanced concurrency control mechanisms

3 Logical clocks For a certain class of algorithms, it is the internal consistency of the clocks that matters, not whether they are particularly close to the real time. If two processes do not interact, it is not necessary that their clocks be synchronized. (Lamport) What usually matters is that they agree on the order in which events occur. (Lamport) Happens before relation: ( ) –If a and b are in the same process, and a occurs before b, then –If a is sending a message, and b is receiving that message by another process, then Two events are concurrent if neither nor We need a way of assign a time value to all events that all processes agree that preserves and always increases.

4 Lamport Timestamps a)Three processes, each with its own clock. The clocks run at different rates. b)Lamport's algorithm corrects the clocks. Fig 5-7 (p. 254) Sometimes an additional requirement: no two events occur at exactly the same time Solution: attach the number of the process in which the event occurs to the low-order end of the time, separated by a decimal point.

5 Example: Totally-Ordered Multicasting Updating a replicated database and leaving it in an inconsistent state. Lamport timestamps can be used to implement totally-ordered multicast in a distributed fashion.

6 Totally-ordered multicast Assume that messages from the same sender are received in the order they were sent, and that no messages are lost. When a process receives a message, it is put into a local queue, ordered according to its timestamp. The receiver multicasts an acknowledgement to the other processes. All processes will eventually have the same copy of the local queue. The timestamps reflect a consistent global ordering of events. A process can deliver a queued message to the application it is running only when that message is at the head of the queue and has been acknowledged by each other process.

7 Vector timestamp With Lamport timestamps, nothing can be said about the relationship between two events a and b by comparing their time values C(a) and C(b). The problem is that Lamport timestamps do not capture causality. A vector timestamp VT(a) assigned to an event a has the property that if VT(a) < VT(b) then a is known to causally precede b. It is constructed by letting each process maintain a vector such that – is the number of events that have occurred so far at –If then knows that k events have occurred at

8 Vector timestamp The first property is maintained by incrementing at the occurrence of each new event at The second property is maintained by piggybacking vectors vt along with messages that are sent. When process receives a message m, it adjusts its own vector by setting all to Then is increased by 1 Messages could be delivered only when no causality constrains are violated. Consider the case in p. 257.

9 Global State – distributed snapshot a)A consistent cut b)An inconsistent cut The global state of a distributed system consists of the local state of each process, plus the messages that are currently in transit.

10 Global State (2) a)Organization of a process and channels for a distributed snapshot

11 Global State (3) b)Process Q receives a marker for the first time and records its local state c)Q records all incoming message d)Q receives a marker for its incoming channel and finishes recording the state of the incoming channel When Q has received a marker along each incoming channel, and processed each one, its recorded local state and the state for each incoming channel can be collected and sent to the process that initiated the snapshot.

12 Termination Detection If Q receives the marker from P requesting a snapshot for the first time, it considers P its predecessor. When Q completes its part of the snapshot, it sends its predecessor a DONE message. When the initiator has received a DONE message from all its successors, it knows the snapshot is complete. However, a snapshot may show a global state in which messages are still in transit. What is needed is a snapshot in which all channels are empty.

13 Termination Detection A modification: –When Q finishes its part of the snapshot, it returns a DONE to its predecessor only when All of Q’s successors have returned a DONE message Q has not received any message between the point it recorded its state, and the point it had received the marker along each of its incoming channels. –Otherwise, Q returns a CONTINUE message to its predecessor –When the initiator receives only DONE messages from its successors, the computation is complete. Otherwise, it initiates another snapshot.

14 Election Algorithms Election algorithms attempt to locate the process with the highest process number and designate it as coordinator. Assumes that every process knows the process number of every other process. What the processes do not know is which ones are currently up and which ones are currently down. 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.

15 The Bully Algorithm When any process notices that the coordinator is no longer responding to requests, it initiates an election. A process P holds an election as follows: 1.P sends an ELECTION message to all processes with higher numbers. 2.If no one responds, P wins the election and becomes coordinator 3.If one of the higher-ups answers, it takes over. P’s job is done. When an ELECTION message is received by a process, the receiver sends an OK message back. It then holds an election, unless it is already holding one. Eventually, the winner announces its victory by sending all processes a COORDINATOR message. If a process that was previously down comes back up, it holds an election.

16 The Bully Algorithm 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

17 Global State (3) d)Process 6 tells 5 to stop e)Process 6 wins and tells everyone

18 A Ring Algorithm Election algorithm using a ring, in which both 2 and 5 discover the previous coordinator 7 has crashed.

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

20 A Centralized Algorithm Advantages: –Guarantees mutual exclusion –Fair –Requires only three messages per use of a critical region (request, grant, release) Shortcomings –Single point of failure –If processes normally blocks after making request, they cannot distinguish a dead coordinator from “permission denied”. –In a large system, a single coordinator becomes a performance bottleneck.