Distributed Mutual Exclusion

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

Coordination and Agreement

Distributed Systems. coordination Johan Montelius ID2201. Distributed Systems ID2201

Distributed Mutual Exclusion Algorithms

A Token Based Distributed Mutual Exclusion Algorithm based on Quorum Agreements

CSE 486/586 Distributed Systems

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

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

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

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

DISTRIBUTED MUTEX. EE324 Lecture 11

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

International Journal of Computer Engineering and Applications, Volume XII, Issue I, Jan. 18, ISSN

PROCESS SYNCHRONIZATION

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

Mutual Exclusion. A Centralized Algorithm

Frequently asked questions from the previous class survey

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

Ye-In Chang. National Sun Yat-Sen University. Kaohsiung, Taiwan. Republic of China. Abstract

Distributed Systems (5DV147)

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

Process Synchroniztion Mutual Exclusion & Election Algorithms

An Efficient Distributed Mutual Exclusion Algorithm Based on Relative Consensus Voting

Distributed Synchronization. EECS 591 Farnam Jahanian University of Michigan

Lock Based Distributed Data Structures

Self Stabilization. CS553 Distributed Algorithms Prof. Ajay Kshemkalyani. by Islam Ismailov & Mohamed M. Ali

CSE 5306 Distributed Systems

CSE 5306 Distributed Systems. Synchronization

Distributed Operating Systems. Distributed Synchronization

Distributed Coordination! Distr. Systems: Fundamental Characteristics!

Event Ordering Silberschatz, Galvin and Gagne. Operating System Concepts

A Dynamic Distributed Algorithm for Read Write Locks

Using Maekawa s Algorithm to Perform Distributed Mutual Exclusion in Quorums

A Novel Approach to Allow Process into Critical Section with no delay-time

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

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

Chapter 16: Distributed Synchronization

Homework #2 Nathan Balon CIS 578 October 31, 2004

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

Chapter 18: Distributed

VALLIAMMAI ENGINEERING COLLEGE

A Delay-Optimal Group Mutual Exclusion Algorithm for a Tree Network

How Bitcoin achieves Decentralization. How Bitcoin achieves Decentralization

Chapter 6 Synchronization

Distributed Mutual Exclusion

Distributed Systems - I

Event Ordering. Greg Bilodeau CS 5204 November 3, 2009

Distributed Systems Coordination and Agreement

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

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

Mutual Exclusion in DS

Distributed Systems. Chapman & Hall/CRC. «H Taylor S* Francis Croup Boca Raton London New York

Exam 2 Review. Fall 2011

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

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

Reducing synchronization cost in distributed multi-resource allocation problem

CSE 5306 Distributed Systems. Consistency and Replication

Time and Coordination in Distributed Systems. Operating Systems

Verteilte Systeme (Distributed Systems)

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

Silberschatz and Galvin Chapter 18

Distributed Systems - II

Synchronization. Chapter 5

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

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

Algorithm 23 works. Instead of a spanning tree, one can use routing.

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

Concurrency Control in Distributed Systems. ECE 677 University of Arizona

殷亚凤. Consistency and Replication. Distributed Systems [7]

The Prioritized and Distributed Synchronization in Distributed Groups

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

Synchronization. Clock Synchronization

DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING UNIT-1

殷亚凤. Synchronization. Distributed Systems [6]

CSE 5306 Distributed Systems

Concurrency: Mutual Exclusion and Synchronization

Coupling Thursday, October 21, :23 PM


Module 7 - Replication

CS2506 Quick Revision

Concurrency: Mutual Exclusion and

416 practice questions (PQs)

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

Introduction to Deadlocks

Synchronization. Distributed Systems IT332

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

Design and Performance Evaluation of a New Spatial Reuse FireWire Protocol. Master s thesis defense by Vijay Chandramohan

Operating Systems. Deadlock. User OS. Kernel & Device Drivers. Interface Programs. Brian Mitchell - Operating Systems

(Pessimistic) Timestamp Ordering. Rules for read and write Operations. Read Operations and Timestamps. Write Operations and Timestamps

Slides for Chapter 12: Coordination and Agreement

Distributed Systems Question Bank UNIT 1 Chapter 1 1. Define distributed systems. What are the significant issues of the distributed systems?

Algorithms and protocols for distributed systems

Arranging lunch value of preserving the causal order. a: how about lunch? meet at 12? a: <receives b then c>: which is ok?

(Pessimistic) Timestamp Ordering

Distributed Systems 8L for Part IB

Lecture 7: Logical Time

Distributed Transaction Management 2003

Important Lessons. A Distributed Algorithm (2) Today's Lecture - Replication

Sigma: A Fault-Tolerant Mutual Exclusion Algorithm in Dynamic Distributed Systems Subject to Process Crashes and Memory Losses

A Distributed Algorithm for Power Management in Mobile Ad-Hoc Networks

Transcription:

Distributed Mutual Exclusion

Mutual Exclusion Well-understood in shared memory systems Requirements: at most one process in critical section (safety) if more than one requesting process, someone enters (liveness) a requesting process enters within a finite time (no starvation) requests are granted in some order (fairness)

Some Complexity Measures No. of messages per critical section entry Synchronization delay Response time Throughput

Classification of Distributed Mutual Exclusion Algorithms Permission based Node takes permission from all/subset of other nodes before entering critical section Permission from all: costly, good for small systems Permission from subset: scalable, widely used Main problem: How to choose the subsets for each node? Token based Single token in the system Node enters critical section if it has the token Algorithms differ in how the token is circulated among requesting nodes

Adaptive vs. Non-Adaptive Performance under low load (less requests for CS) should be better than performance under high load (lots of requests) Adaptive mutual exclusion algorithms: performance is dependent on load

Permission based Algorithms

Lamport s Algorithm Permission from all Given as an example of use of logical clocks for ordering requests Model: asynchronous system, completely connected topology, reliable FIFO channels Better algorithms exist even in the class of permission from all, but good to study first as a base to understand those

Every node i has a request queue q i, keeps requests sorted by logical timestamps (total ordering enforced by including process id in the timestamps) To request critical section: send timestamped REQUEST (ts i, i) to all other nodes put (ts i, i) in its own queue On receiving a request (ts i, i): send timestamped REPLY to the requesting node i put request (ts i, i) in the queue

To enter critical section: i enters critical section if (ts i, i) is at the top if its own queue, and i has received a message (any message) with timestamp larger than (ts i, i) from ALL other nodes. To release critical section: i removes its request from its own queue and sends a timestamped RELEASE message to all other nodes On receiving a RELEASE message from i, i s request is removed from the local request queue

Some points to note Purpose of REPLY messages from node i to j is to ensure that j knows of all requests of i prior to sending the REPLY (and therefore, possibly any request of i with timestamp lower than j s request) Requests are granted in order of increasing timestamps Requires FIFO channels. 3(n 1 ) messages per critical section invocation Synchronization delay = max. message transmission time

Ricart-Agarwala Algorithm Improvement over Lamport s Main Idea: node j need not send a REPLY to node i if j has a request with timestamp lower than the request of i (since i cannot enter before j anyway in this case) REPLY sent after j satisfies its own request No separate RELEASE message needed Requests still granted in order of increasing timestamps Does not require FIFO Still requires knowledge of all other nodes in the network 2(n 1) messages per critical section invocation Synchronization delay = max. message transmission time

To request critical section: send timestamped REQUEST message (ts i, i) On receiving request (ts i, i) at j: send REPLY to i if j is neither requesting nor executing critical section or if j is requesting and i s request timestamp is smaller than j s request timestamp. Otherwise, defer the request. To enter critical section: i enters critical section on receiving REPLY from all nodes To release critical section: send REPLY to all deferred requests

Maekawa s Algorithm Permission obtained from only a subset of other processes, called the Request Set (or Quorum) Separate Request Set R i for each process i Requirements: for all i, j: R i R j Φ for all i: i Є R i for all i: R i = K, for some K any node i is contained in exactly D Request Sets, for some D K = D (easy to see) For minimum K, K sqrt(n) (why?)

A simple version To request critical section: i sends REQUEST message to all processes in Ri On receiving a REQUEST message: send a REPLY message if no REPLY message has been sent since the last RELEASE message is received. Update status to indicate that a REPLY has been sent. Otherwise, queue up the REQUEST To enter critical section: i enters critical section after receiving REPLY from all nodes in Ri

To release critical section: send RELEASE message to all nodes in R i On receiving a RELEASE message, send REPLY to next node in queue and delete the node from the queue. If queue is empty, update status to indicate no REPLY message has been sent since last RELEASE is received.

Message Complexity: 3*sqrt(N) Synchronization delay = 2 *(max message transmission time) Major problem: Deadlock possible Can you update the protocol with additional messages to solve this problem? Good practice Maekawa s protocol already does that, we just looked at a part of it Building the request sets?

Some Points Permission based algorithms with permission from a subset are widely used Voting/Quorum based protocols In Maekawa s algorithm, each process has one vote A process needs a certain number of votes to proceed Questions/Issues How to choose the quorums? Should the quorum be the same for read and write? Should each process have one vote only? Same number of votes for all? Dynamic quorums/votes

Token based Algorithms

Token based Algorithms Single token circulates, enter CS when token is present Mutual exclusion obvious Algorithms differ in how to find and get the token Token circulates, nodes use it when it passes through them Token stays at node of last use, other nodes request for it when needed Need to differentiate between old and current requests

Suzuki Kasami Algorithm Broadcast a request for the token Process with the token sends it to the requestor if it does not need it Issues: Current vs. outdated requests Determining sites with pending requests Deciding which site to give the token to

The token: Queue (FIFO) Q of requesting processes LN[1..n] : sequence number of request that j executed most recently The request message: REQUEST(i, k): request message from node i for its k th critical section execution Other data structures RN i [1..n] for each node i, where RN i [j] is the largest sequence number received so far by i in a REQUEST message from j.

To request critical section: If i does not have token, increment RN i [i] and send REQUEST(i, RN i [i]) to all nodes if i has token already, enter critical section if the token is idle (no pending requests in token Q), else follow rule to release critical section On receiving REQUEST(i, sn) at j: set RN j [i] = max(rn j [i], sn) if j has the token and the token is idle, send it to i if RN j [i] = LN[i] + 1. If token is not idle, follow rule to release critical section

To enter critical section: enter CS if token received after sending REQUEST To release critical section: set LN[i] = RNi[i] For every node j which is not in Q (in token), add node j to Q if RNi[ j ] = LN[ j ] + 1 If Q is non empty after the above, delete first node from Q and send the token to that node

Points to note: No. of messages: 0 if node holds the token already and token is idle, n otherwise Synchronization delay: 0 (node has the token) or max. message delay (token is elsewhere) No starvation

Raymond s Algorithm Forms a directed tree (logical) with the token-holder as root Each node has variable Holder that points to its parent on the path to the root. Root s Holder variable points to itself Each node i has a FIFO request queue Q i

To request critical section: Send REQUEST to parent on the tree, provided i does not hold the token currently and Q i is empty. Then place request in Qi When a non-root node j receives a request from i place request in Q j send REQUEST to parent if no previous REQUEST sent

When the root r receives a REQUEST place request in Q r if token is idle, follow rule for releasing critical section (shown later) When a node receives the token delete first entry from the queue send token to that node (maybe itself) set Holder variable to point to that node if queue is non-empty, send a REQUEST message to the parent (node pointed at by Holder variable)

To execute critical section enter if token is received and own entry is at the top of the queue; delete the entry from the queue To release critical section if queue is non-empty, delete first entry from the queue, send token to that node and make Holder variable point to that node If queue is still non-empty, send a REQUEST message to the parent (node pointed at by Holder variable)

Complexity: Avg. message per CS entry O(log n) and sync. delay (T log n)/2, where T = max. message delay (empirical result) Interestingly, messages per CS entry is O(1) at high load! Adaptive algorithm in a nice way, better during high load

l - Exclusion At most l processes can be in critical section at any one time Can be implemented with l tokens Other algorithms exist