Mutual Exclusion. A Centralized Algorithm

Similar documents
Distributed Synchronization. EECS 591 Farnam Jahanian University of Michigan

Last Class: Clock Synchronization. Today: More Canonical Problems

PROCESS SYNCHRONIZATION

Distributed Systems. coordination Johan Montelius ID2201. Distributed Systems ID2201

Synchronization. Distributed Systems IT332

Process Synchroniztion Mutual Exclusion & Election Algorithms

Coordination 1. To do. Mutual exclusion Election algorithms Next time: Global state. q q q

Coordination and Agreement

CSE 486/586 Distributed Systems

Synchronization Part 2. REK s adaptation of Claypool s adaptation oftanenbaum s Distributed Systems Chapter 5 and Silberschatz Chapter 17

Algorithms and protocols for distributed systems

Clock Synchronization. Synchronization. Clock Synchronization Algorithms. Physical Clock Synchronization. Tanenbaum Chapter 6 plus additional papers

CSE 5306 Distributed Systems. Synchronization

Chapter 6 Synchronization

殷亚凤. Synchronization. Distributed Systems [6]

CMPSCI 677 Operating Systems Spring Lecture 14: March 9

CS 455: INTRODUCTION TO DISTRIBUTED SYSTEMS [DISTRIBUTED MUTUAL EXCLUSION] Frequently asked questions from the previous class survey

Distributed Operating Systems. Distributed Synchronization

Advanced Topics in Distributed Systems. Dr. Ayman A. Abdel-Hamid. Computer Science Department Virginia Tech

CS455: Introduction to Distributed Systems [Spring 2018] Dept. Of Computer Science, Colorado State University

Synchronization. Chapter 5

Distributed Systems (5DV147)

Frequently asked questions from the previous class survey

CS455: Introduction to Distributed Systems [Spring 2018] Dept. Of Computer Science, Colorado State University

Chapter 6 Synchronization (2)

Synchronization. Clock Synchronization

Last Class: Clock Synchronization. Today: More Canonical Problems

Distributed Systems Coordination and Agreement

DISTRIBUTED MUTEX. EE324 Lecture 11

Synchronization Part II. CS403/534 Distributed Systems Erkay Savas Sabanci University

Operating Systems. Mutual Exclusion in Distributed Systems. Lecturer: William Fornaciari

CSE 5306 Distributed Systems

A Two-Layer Hybrid Algorithm for Achieving Mutual Exclusion in Distributed Systems

SYNCHRONIZATION. DISTRIBUTED SYSTEMS Principles and Paradigms. Second Edition. Chapter 6 ANDREW S. TANENBAUM MAARTEN VAN STEEN

Exam 2 Review. Fall 2011

Homework #2 Nathan Balon CIS 578 October 31, 2004

Verteilte Systeme/Distributed Systems Ch. 5: Various distributed algorithms

Distributed Systems Exam 1 Review. Paul Krzyzanowski. Rutgers University. Fall 2016

Several of these problems are motivated by trying to use solutiions used in `centralized computing to distributed computing

Last Time. 19: Distributed Coordination. Distributed Coordination. Recall. Event Ordering. Happens-before

Synchronization (contd.)

Distributed Systems 8L for Part IB

Distributed Mutual Exclusion

CSE 380 Computer Operating Systems

Event Ordering Silberschatz, Galvin and Gagne. Operating System Concepts

Distributed Mutual Exclusion

Chapter 16: Distributed Synchronization

Recap: Consensus. CSE 486/586 Distributed Systems Mutual Exclusion. Why Mutual Exclusion? Why Mutual Exclusion? Mutexes. Mutual Exclusion C 1

Chapter 18: Distributed

June 22/24/ Gerd Liefländer System Architecture Group Universität Karlsruhe (TH), System Architecture Group

Time and Coordination in Distributed Systems. Operating Systems

Distributed Mutual Exclusion Algorithms

Distributed Systems. Lec 9: Distributed File Systems NFS, AFS. Slide acks: Dave Andersen

Silberschatz and Galvin Chapter 18

Large Systems: Design + Implementation: Communication Coordination Replication. Image (c) Facebook

A Dynamic Resource Synchronizer Mutual Exclusion Algorithm for Wired/Wireless Distributed Systems

Distributed Systems Exam 1 Review Paul Krzyzanowski. Rutgers University. Fall 2016

OUTLINE. Introduction Clock synchronization Logical clocks Global state Mutual exclusion Election algorithms Deadlocks in distributed systems

Concurrency: Mutual Exclusion and Synchronization

Lecture 2: Leader election algorithms.

A Dag-Based Algorithm for Distributed Mutual Exclusion. Kansas State University. Manhattan, Kansas maintains [18]. algorithms [11].

Distributed Coordination! Distr. Systems: Fundamental Characteristics!

Slides for Chapter 12: Coordination and Agreement

Distributed systems. Lecture 6: distributed transactions, elections, consensus and replication. Malte Schwarzkopf

CS 417: the one-hour study guide for exam 2

How Bitcoin achieves Decentralization. How Bitcoin achieves Decentralization

Distributed Systems - II

Slides for Chapter 15: Coordination and Agreement

Concurrency: Mutual Exclusion and

11/7/2018. Event Ordering. Module 18: Distributed Coordination. Distributed Mutual Exclusion (DME) Implementation of. DME: Centralized Approach

Mutual Exclusion in DS

Verteilte Systeme (Distributed Systems)

A Synchronization Algorithm for Distributed Systems

QUESTIONS Distributed Computing Systems. Prof. Ananthanarayana V.S. Dept. Of Information Technology N.I.T.K., Surathkal

A DAG-BASED ALGORITHM FOR DISTRIBUTED MUTUAL EXCLUSION ATHESIS MASTER OF SCIENCE

Distributed Systems Principles and Paradigms

Process groups and message ordering

Design and Implementation of Distributed Algorithms for Their Application in Telematic Services. Use case: Shared Calendar

Distributed Transaction Management 2003

Last time. Distributed systems Lecture 6: Elections, distributed transactions, and replication. DrRobert N. M. Watson

Synchronization. Before We Begin. Synchronization. Credit/Debit Problem: Race Condition. CSE 120: Principles of Operating Systems.

An Efficient Approach of Election Algorithm in Distributed Systems

Distributed Systems COMP 212. Revision 2 Othon Michail

Computing with Infinitely Many Processes under assumptions on concurrency and participation -M.Merritt&G.Taubenfeld. Dean Christakos & Deva Seetharam

Definition of a DS A collection of independent computers that appear to its user as a single coherent system.

Networked Virtual Environments and Distributed Rendering IGS HT Background and history. Background and history. Background and history

416 practice questions (PQs)

Midterm Examination ECE 419S 2015: Distributed Systems Date: March 13th, 2015, 6-8 p.m.

Failure Tolerance. Distributed Systems Santa Clara University

Selected Questions. Exam 2 Fall 2006

Congestion Control in Communication Networks

CSCD 433/533 Advanced Networks Spring Lecture 22 Quality of Service

Interactive Graphical Systems HT2006


An Efficient Distributed Mutual Exclusion Algorithm Based on Relative Consensus Voting

Exam 2 Review. October 29, Paul Krzyzanowski 1

SEGR 550 Distributed Computing. Final Exam, Fall 2011

Homework 3 Discussion

CSCI Spring Final Exam Solution

Chapter 1. Introd uction. Mutual exclusion is one of the first problems met in parallel processmg. The

Transcription:

Mutual Exclusion Processes in a distributed system may need to simultaneously access the same resource Mutual exclusion is required to prevent interference and ensure consistency We will study three algorithms for mutual exclusion: A centralized algorithm A distributed algorithm A token ring algorithm 1 A Centralized Algorithm One process is elected as the coordinator Every process needs to get permission from the coordinator before entering the critical section To obtain exclusive access: sends request message, awaits OK message To release: sends release message Coordinator maintains a queue of waiting processes Upon receiving request message: if resource is available, sends OK message; if not, queues the request Upon receiving release message: removes the oldest request in the queue and sends OK message 2 1

An Example a) Process 1 asks the coordinator for permission to access a shared resource. Permission is granted. b) Process 2 then asks permission to access the same resource. The coordinator does not reply. c) When process 1 releases the resource, it tells the coordinator, which then replies to 2. 3 Properties of the Centralized Algorithm (1) Fair requests are granted in the order in which they are received No starvation no process ever waits forever Simple three messages per use of a resource (request, OK, release) Drawbacks The coordinator is a single point of failure must elect a new coordinator if the current coordinator fails The coordinator can be a performance bottleneck in a large system 4 2

An Improvement to the Centralized Algorithm Processes can not distinguish a dead coordinator from permission denied No response from the coordinator in either case Solution: Upon receiving a request, the coordinator always sends a reply, either granting or denying permission This enables the requester to detect dead coordinator After a request is denied, the sender should block waiting for a subsequent OK message 5 A Distributed Algorithm (1) Developed by Ricart and Agrawala [1981] The algorithm implements mutual exclusion between a set of peer processes A process can enter the critical section only when it has got permission from all other processes Each process maintains a logical clock Process i enters critical section as follows 1. Multicasts a request message (L i,i) to all other processes (L i is process i s current logical time) 2. Waits until a reply is received from every other process 3. Enters critical section 6 3

A Distributed Algorithm (2) When process j receives a request message If outside the critical section, sends an OK message If in the critical section, does not reply and queues the request If has sent a request to enter the critical section, sends an OK message if (L i,i) < (L j,j), else queues the request When a process exits the critical section, it sends OK messages to all processes in its queue and remove these processes from the queue If two or more processes request entry at the same time, the process whose request bears the lowest timestamp (process ID used for tie breaking) will be the first to enter the critical section 7 An Example 2 a) Two processes want to access a shared resource at the same time. b) Process 0 has the lowest timestamp, so it wins. c) When process 0 is done, it sends OK to process 2, so process 2 can now go ahead. 8 4

Properties of the Distributed Algorithm Fully distributed: no coordinator needed No starvation All processes are involved in all decisions N points of failure! Any overloaded process can become a bottleneck Improvements Upon receiving a request, a process always sends a reply, either granting or denying permission this enables the detection of a dead process A process can enter the critical section when it has got permission from a simple majority of the other processes 9 A Token Ring Algorithm Processes are arranged in a logical ring A token is passed from process to process around the ring A process must obtain the token before entering the critical section; it passes the token to its neighbor when it exits the critical section A process passes the token to its neighbor if it does not require to enter the critical section (a) An unordered group of processes on a network. (b) a logical ring constructed in software. 10 5

Properties of the Token Ring Algorithm Fully distributed: no coordinator needed No starvation The algorithm continuously consumes network bandwidth The token circulates around the ring even when no process requires entry to the critical section If the token is lost, it must be regenerated How to detect token loss? A dead process can break the ring How to detect a dead process? 11 Comparison of Mutual Exclusion Algorithms Algorithm Messages per entry/exit Delay before entry (in message times) Problems Centralized 3 2 Coordinator crash Distributed 2(n 1) 2(n 1) Crash of any process Token ring 1 to infinity 0 to n 1 Lost token, process crash 12 6