Global State (1) a)A consistent cut b)An inconsistent cut.

Slides:



Advertisements
Similar presentations
Dr. Kalpakis CMSC621 Advanced Operating Systems 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.
Synchronization. Why Synchronize? Often important to control access to a single, shared resource. Also often important to agree on the ordering of events.
1 Algorithms and protocols for distributed systems We have defined process groups as having peer or hierarchical structure and have seen that a coordinator.
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. Physical Clocks Solar Physical Clocks Cesium Clocks International Atomic Time Universal Coordinate Time (UTC) Clock Synchronization Algorithms.
Database management concepts Database Management Systems (DBMS) An example of a database (relational) Database schema (e.g. relational) Data independence.
Synchronization Clock Synchronization Logical Clocks Global State Election Algorithms Mutual Exclusion.
Synchronization Part 2 REK’s adaptation of Claypool’s adaptation ofTanenbaum’s Distributed Systems Chapter 5 and Silberschatz Chapter 17.
Synchronization Chapter 5.
Synchronization in Distributed Systems. Mutual Exclusion To read or update shared data, a process should enter a critical region to ensure mutual exclusion.
Synchronization Tanenbaum Chapter 5. Synchronization Multiple processes sometimes need to agree on order of a sequence of events. This requires some synchronization,
EEC-681/781 Distributed Computing Systems Lecture 11 Wenbing Zhao Cleveland State University.
EEC-681/781 Distributed Computing Systems Lecture 12 Wenbing Zhao Cleveland State University.
EEC-681/781 Distributed Computing Systems Lecture 11 Wenbing Zhao Cleveland State University.
1 Synchronization  Clock Synchronization  and algorithm.
1 Synchronization Synchronization in centralized systems is easy. Synchronization in distributed systems is much more difficult to achieve. Why do we need.
CS4513 Distributed Computer Systems Synchronization (Ch 5)
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.
Synchronization.
Synchronization Chapter 6 Part III Transactions. –Most of the lecture notes are based on slides by Prof. Jalal Y. Kawash at Univ. of Calgary –Some slides.
Tanenbaum & Van Steen, Distributed Systems: Principles and Paradigms, 2e, (c) 2007 Prentice-Hall, Inc. All rights reserved DISTRIBUTED SYSTEMS.
CIS 720 Concurrency Control. Locking Atomic statement –Can be used to perform two or more updates atomically Th1: …. ;……. Th2:…………. ;…….
Synchronization Chapter 6
1 Synchronization. 2 Why Synchronize?  Often important to control access to a single, shared resource.  Also often important to agree on the ordering.
Tanenbaum & Van Steen, Distributed Systems: Principles and Paradigms, 2e, (c) 2007 Prentice-Hall, Inc. All rights reserved Chapter 6 Synchronization.
4.5 DISTRIBUTED MUTUAL EXCLUSION MOSES RENTAPALLI.
Lecture 5: Sun: 1/5/ Distributed Algorithms - Distributed Databases Lecturer/ Kawther Abas CS- 492 : Distributed system &
Computer Science Lecture 12, page 1 CS677: Distributed OS Last Class Vector timestamps Global state –Distributed Snapshot Election algorithms –Bully algorithm.
Real-Time & MultiMedia Lab Synchronization Chapter 5.
1 Mutual Exclusion: A Centralized Algorithm a)Process 1 asks the coordinator for permission to enter a critical region. Permission is granted b)Process.
Coordination and Agreement. Topics Distributed Mutual Exclusion Leader Election.
DC6: Chapter 12 Coordination Election Algorithms Distributed Mutual Exclusion Consensus Group Communication.
Synchronization CSCI 4780/6780. Mutual Exclusion Concurrency and collaboration are fundamental to distributed systems Simultaneous access to resources.
Presenter: Long Ma Advisor: Dr. Zhang 4.5 DISTRIBUTED MUTUAL EXCLUSION.
Distributed Systems Principles and Paradigms Chapter 05 Synchronization.
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.
Computer Science Lecture 13, page 1 CS677: Distributed OS Last Class: Canonical Problems Election algorithms –Bully algorithm –Ring algorithm Distributed.
Synchronization Chapter Contents qClock Synchronization qLogical Clocks qGlobal State qElection Algorithms qMutual Exclusion qDistributed Transactions.
Synchronization Chapter 5. Table of Contents Clock Synchronization Logical Clocks Global State Election Algorithms Mutual Exclusion.
3. Synchronization in Distributed Systems
Chapter 5 Synchronization Presenter: Maria Riaz. Distributed Systems – Fall 2004 – Prof. SY Lee2 Sequence of Presentation Synchronization Clock Synchronization.
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.
Synchronization. Clock Synchronization In a centralized system time is unambiguous. In a distributed system agreement on time is not obvious. When each.
Synchronization CSCI 4900/6900. Transactions Protects data and allows processes to access and modify multiple data items as a single atomic transaction.
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.
CSC 8420 Advanced Operating Systems Georgia State University Yi Pan Transactions are communications with ACID property: Atomicity: all or nothing Consistency:
Lecture on Synchronization Submitted by
Synchronization Tanenbaum Chapter 5. Synchronization Multiple processes sometimes need to agree on order of a sequence of events. This requires some synchronization,
Computer Science Lecture 13, page 1 CS677: Distributed OS Last Class: Canonical Problems Election algorithms –Bully algorithm –Ring algorithm Distributed.
Atomic Tranactions. Sunmeet Sethi. Index  Meaning of Atomic transaction.  Transaction model Types of storage. Transaction primitives. Properties of.
Distributed Systems 31. Theoretical Foundations of Distributed Systems - Coordination Simon Razniewski Faculty of Computer Science Free University of Bozen-Bolzano.
Last Class: Canonical Problems
Mutual Exclusion What is mutual exclusion? Single processor systems
Outline Distributed Mutual Exclusion Introduction Performance measures
Database management concepts
Synchronization (2) – Mutual Exclusion
Prof. Leonardo Mostarda University of Camerino
Presentation transcript:

Global State (1) a)A consistent cut b)An inconsistent cut

Election Algorithms The idea behind these algorithm is to have the ability to elect a unique coordinator process from the currently running processes. Some assumptions: Every process has a unique priority number. –It can be a concatenated with the IP address and the process' priority number. –However, this may not be desirable especially if the process' IP address is a high number

Election Algorithms Some more assumptions: Whenever an election is held, the process with the highest priority number will be elected. When the failed leader recovers, it can take appropriate action to rejoin the set of active processes. When it returns and if it has the highest priority, it will be the new leader.

Bully Algorithm Devised by Garcia-Molina, 1982 Assume every process knows the priority number of every other process in the system. It is broadcasted so that everyone knows it Suppose P sends REQUEST to coordinator. P waits a while so that REQUEST times out (the coordinator times out) P assumes the coordinator has failed P then initiates an election

Bully Algorithm To initiate an election: 1.P sends an ELECTION message to every process with a higher process ID. 2.If no one responds, P wins the election and becomes the coordinator 3.If one of the higher-up processes answers, it takes over. P waits for the final response from the new coordinator

Bully Algorithm If P receives and ELECTION message This means that some other process below me is holding an election P sends a response to the sending process P holds an election (as above) if it is not already holding one The election process gradually move to the process with the highest priority number

Bully Algorithm How a recovered process rejoins the system: If a failed process recovers then it initiates an election. Even if it's the bottom process, it still initiates an election so that it can identify who the coordinator is.

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

Bully Algorithm Example d)Process 6 tells 5 to stop e)Process 6 wins and tells everyone

A Ring Algorithm Election algorithm using a ring.

Mutual Exclusion The idea of mutual exclusion in distributed systems is to guarantee that either a  b or b  a, that is, that a and b are not concurrent Examples of applications that require this file sharing in NFS implementation of distributed shared memory, The approach can either be centralized or distributed. A centralized approach requires a central coordinator it is not fault tolerant since there is a single point of failure, and it can be a performance bottleneck.

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

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

Distributed Mutual Exclusion Next paper: Mamoru Maekawa, "A SQRT(N) Algorithm for mutual exclusion in decentralized systems," ACM Transactions on Computer Systems, Vol. 3, No. 2, May 1985, p ,

A Token Ring Algorithm a)An unordered group of processes on a network. b)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

The Transaction Model (1) Updating a master tape is fault tolerant.

The Transaction Model (2) Examples of primitives for transactions. PrimitiveDescription BEGIN_TRANSACTIONMake the start of a transaction END_TRANSACTIONTerminate the transaction and try to commit ABORT_TRANSACTIONKill the transaction and restore the old values READRead data from a file, a table, or otherwise WRITEWrite data to a file, a table, or otherwise

The Transaction Model (3) a)Transaction to reserve three flights commits b)Transaction aborts when third flight is unavailable BEGIN_TRANSACTION reserve WP -> JFK; reserve JFK -> Nairobi; reserve Nairobi -> Malindi; END_TRANSACTION (a) BEGIN_TRANSACTION reserve WP -> JFK; reserve JFK -> Nairobi; reserve Nairobi -> Malindi full => ABORT_TRANSACTION (b)

Transaction are: a)Atomic: To the outside world the transaction happens indivisibly b)Consistent: The transaction does not violate system invariants c)Isolated: Concurrent transactions do not interfere with each other d)Durable: Once a transaction commits, the changes are permanent These properties are the ACID properties of transactions. Flat transactions are the simplest type of transaction – but are limited because they do not allow partial results to be committed or aborted.

Distributed Transactions a)A nested transaction b)A distributed transaction

Private Workspace a)The file index and disk blocks for a three-block file b)The situation after a transaction has modified block 0 and appended block 3 c)After committing

Writeahead Log a) A transaction b) – d) The log before each statement is executed x = 0; y = 0; BEGIN_TRANSACTION; x = x + 1; y = y + 2 x = y * y; END_TRANSACTION; (a) Log [x = 0 / 1] (b) Log [x = 0 / 1] [y = 0/2] (c) Log [x = 0 / 1] [y = 0/2] [x = 1/4] (d)

Concurrency Control (1) General organization of managers for handling transactions.

Concurrency Control (2) General organization of managers for handling distributed transactions.

Serializability a) – c) Three transactions T 1, T 2, and T 3 d) Possible schedules BEGIN_TRANSACTION x = 0; x = x + 1; END_TRANSACTION (a) BEGIN_TRANSACTION x = 0; x = x + 2; END_TRANSACTION (b) BEGIN_TRANSACTION x = 0; x = x + 3; END_TRANSACTION (c) Schedule 1x = 0; x = x + 1; x = 0; x = x + 2; x = 0; x = x + 3Legal Schedule 2x = 0; x = 0; x = x + 1; x = x + 2; x = 0; x = x + 3;Legal Schedule 3x = 0; x = 0; x = x + 1; x = 0; x = x + 2; x = x + 3;Illegal (d)

Two-Phase Locking (1) Two-phase locking.

Two-Phase Locking (2) Strict two-phase locking.

Pessimistic Timestamp Ordering Concurrency control using timestamps.