Lecture 7- 1 CS 425/ECE 428/CSE424 Distributed Systems (Fall 2009) Lecture 7 Distributed Mutual Exclusion Section 12.2 Klara Nahrstedt.

Slides:



Advertisements
Similar presentations
Dr. Kalpakis CMSC 621, Advanced Operating Systems. Distributed Mutual Exclusion.
Advertisements

CS542 Topics in Distributed Systems Diganta Goswami.
Ricart and Agrawala’s Algorithm
Token-Dased DMX Algorithms n LeLann’s token ring n Suzuki-Kasami’s broadcast n Raymond’s tree.
Page 1 Mutual Exclusion* Distributed Systems *referred to slides by Prof. Paul Krzyzanowski at Rutgers University and Prof. Mary Ellen Weisskopf at University.
CS 582 / CMPE 481 Distributed Systems
Distributed Systems Fall 2009 Coordination and agreement, Multicast, and Message ordering.
Operating Systems, 2011, Danny Hendler & Amnon Meisels 1 Distributed Mutual Exclusion  Introduction  Ricart and Agrawala's algorithm  Raymond's algorithm.
EEC-681/781 Distributed Computing Systems Lecture 11 Wenbing Zhao Cleveland State University.
CS 425 / ECE 428 Distributed Systems Fall 2014 Indranil Gupta (Indy) Lecture 12: Mutual Exclusion All slides © IG.
Distributed Mutual Exclusion Béat Hirsbrunner References G. Coulouris, J. Dollimore and T. Kindberg "Distributed Systems: Concepts and Design", Ed. 4,
Computer Science Lecture 12, page 1 CS677: Distributed OS Last Class Vector timestamps Global state –Distributed Snapshot Election algorithms.
Lecture 2-1 CS 425/ECE 428 Distributed Systems Lecture 2 Time & Synchronization Reading: Klara Nahrstedt.
Lecture 3-1 Computer Science 425 Distributed Systems Lecture 3 Logical Clock and Global States/ Snapshots Reading: Chapter 11.4&11.5 Klara Nahrstedt.
Computer Science 425 Distributed Systems (Fall 2009) Lecture 5 Multicast Communication Reading: Section 12.4 Klara Nahrstedt.
Dr. Kalpakis CMSC 621, Advanced Operating Systems. Fall 2003 URL: Distributed Mutual Exclusion.
Distributed Mutex EE324 Lecture 11.
Distributed Mutual Exclusion
CSE 486/586, Spring 2013 CSE 486/586 Distributed Systems Mutual Exclusion Steve Ko Computer Sciences and Engineering University at Buffalo.
4.5 DISTRIBUTED MUTUAL EXCLUSION MOSES RENTAPALLI.
4.5 Distributed Mutual Exclusion Ranjitha Shivarudraiah.
CSE 486/586, Spring 2012 CSE 486/586 Distributed Systems Mutual Exclusion Steve Ko Computer Sciences and Engineering University at Buffalo.
MUTUAL EXCLUSION AND QUORUMS CS Distributed Mutual Exclusion Given a set of processes and a single resource, develop a protocol to ensure exclusive.
Computer Science Lecture 12, page 1 CS677: Distributed OS Last Class Vector timestamps Global state –Distributed Snapshot Election algorithms –Bully algorithm.
CS425 /CSE424/ECE428 – Distributed Systems – Fall 2011 Material derived from slides by I. Gupta, M. Harandi, J. Hou, S. Mitra, K. Nahrstedt, N. Vaidya.
Coordination and Agreement. Topics Distributed Mutual Exclusion Leader Election.
CS 425/ECE 428/CSE424 Distributed Systems (Fall 2009) Lecture 8 Leader Election Section 12.3 Klara Nahrstedt.
Presenter: Long Ma Advisor: Dr. Zhang 4.5 DISTRIBUTED MUTUAL EXCLUSION.
Studying Different Problems from Distributed Computing Several of these problems are motivated by trying to use solutiions used in `centralized computing’
Lecture 11-1 Computer Science 425 Distributed Systems CS 425 / CSE 424 / ECE 428 Fall 2010 Indranil Gupta (Indy) September 28, 2010 Lecture 11 Leader Election.
Lecture 10 – Mutual Exclusion Distributed Systems.
CS 425/ECE 428/CSE424 Distributed Systems (Fall 2009) Lecture 9 Consensus I Section Klara Nahrstedt.
CSE 486/586, Spring 2012 CSE 486/586 Distributed Systems Mutual Exclusion & Leader Election Steve Ko Computer Sciences and Engineering University.
Physical clock synchronization Question 1. Why is physical clock synchronization important? Question 2. With the price of atomic clocks or GPS coming down,
ITEC452 Distributed Computing Lecture 6 Mutual Exclusion Hwajung Lee.
Hwajung Lee. Mutual Exclusion CS p0 p1 p2 p3 Some applications are:  Resource sharing  Avoiding concurrent update on shared data  Controlling the.
Hwajung Lee. Mutual Exclusion CS p0 p1 p2 p3 Some applications are: 1. Resource sharing 2. Avoiding concurrent update on shared data 3. Controlling the.
Computer Science 425 Distributed Systems (Fall 2009) Lecture 6 Multicast/Group Communication and Mutual Exclusion Section &12.2.
CS 425 / ECE 428 Distributed Systems Fall 2015 Indranil Gupta (Indy) Oct 1, 2015 Lecture 12: Mutual Exclusion All slides © IG.
Lecture 10: Coordination and Agreement (Chap 12) Haibin Zhu, PhD. Assistant Professor Department of Computer Science Nipissing University © 2002.
A Tree Based Algorithm fro Distributed Mutual Exclusion Addy Gronquist 11/19/2003.
Election Distributed Systems. Algorithms to Find Global States Why? To check a particular property exist or not in distributed system –(Distributed) garbage.
Page 1 Mutual Exclusion & Election Algorithms Paul Krzyzanowski Distributed Systems Except as otherwise noted, the content.
Lecture 12-1 Computer Science 425 Distributed Systems CS 425 / CSE 424 / ECE 428 Fall 2012 Indranil Gupta (Indy) October 4, 2012 Lecture 12 Mutual Exclusion.
Lecture 4-1 Computer Science 425 Distributed Systems (Fall2009) Lecture 4 Chandy-Lamport Snapshot Algorithm and Multicast Communication Reading: Section.
From Coulouris, Dollimore, Kindberg and Blair Distributed Systems: Concepts and Design Edition 5, © Addison-Wesley 2012 Slides for Chapter 15: Coordination.
Decentralized solution 1
CIS 825 Review session. P1: Assume that processes are arranged in a ring topology. Consider the following modification of the Lamport’s mutual exclusion.
Mutual Exclusion Algorithms. Topics r Defining mutual exclusion r A centralized approach r A distributed approach r An approach assuming an organization.
Hwajung Lee. Mutual Exclusion CS p0 p1 p2 p3 Some applications are:  Resource sharing  Avoiding concurrent update on shared data  Controlling the.
CSC 8420 Advanced Operating Systems Georgia State University Yi Pan Transactions are communications with ACID property: Atomicity: all or nothing Consistency:
CS 425 / ECE 428 Distributed Systems Fall 2015 Indranil Gupta (Indy) Oct 1, 2015 Lecture 12: Mutual Exclusion All slides © IG.
Slides for Chapter 11: Coordination and Agreement From Coulouris, Dollimore and Kindberg Distributed Systems: Concepts and Design Edition 3, © Addison-Wesley.
Lecture 18: Mutual Exclusion
Coordination and Agreement
Mutual Exclusion Continued
Distributed Mutual Exclusion
Distributed Mutual Exclusion
Decentralized solution 1
Mutual Exclusion Problem Specifications
ITEC452 Distributed Computing Lecture 7 Mutual Exclusion
Outline Distributed Mutual Exclusion Introduction Performance measures
Mutual Exclusion CS p0 CS p1 p2 CS CS p3.
CSE 486/586 Distributed Systems Mutual Exclusion
Synchronization (2) – Mutual Exclusion
ITEC452 Distributed Computing Lecture 7 Mutual Exclusion
Distributed Mutual Exclusion
Distributed Systems and Concurrency: Synchronization in Distributed Systems Majeed Kassis.
Distributed Mutual eXclusion
CSE 486/586 Distributed Systems Mutual Exclusion
Presentation transcript:

Lecture 7- 1 CS 425/ECE 428/CSE424 Distributed Systems (Fall 2009) Lecture 7 Distributed Mutual Exclusion Section 12.2 Klara Nahrstedt

Lecture 7- 2 Acknowledgement The slides during this semester are based on ideas and material from the following sources: –Slides prepared by Professors M. Harandi, J. Hou, I. Gupta, N. Vaidya, Y-Ch. Hu, S. Mitra. –Slides from Professor S. Gosh’s course at University o Iowa.

Lecture 7- 3 Administrative Homework 1 posted September 3, Thursday –Deadline, September 17 (Thursday) MP1 posted September 8, Tuesday –Deadline, September 25 (Friday), 4-6pm Demonstrations

Lecture 7- 4 Plan for today Distributed Mutual Exclusion –Centralized coordinator-based approach –Token-based approach –Ricart and Agrawala’s timestamp algorithm –Maekawa’s algorithm –Raymond’s algorithm

Lecture 7- 5 Distributed Mutual Exclusion: Performance Evaluation Criteria Bandwidth: the total number of messages sent in each entry and exit operation. Delay: –Client delay: the delay incurred by a process at each entry and exit operation (when no other process is waiting) –Synchronization delay: the time interval between one process exiting the critical section and the next process entering it (when there is only one process waiting) These translate into throughput -- the rate at which the processes can access the critical section, i.e., x processes per second. (these definitions more correct than the ones in the textbook)

Lecture 7- 6 Assumptions For all the algorithms studied, we assume –Reliable FIFO channels between every process pair »Each pair of processes is connected by reliable channels (such as TCP). Messages are eventually delivered to recipients’ input buffer in FIFO order. –Processes do not fail.

Lecture 7- 7  A central coordinator or leader L  Is appointed or elected  Grants permission to enter CS & keeps a queue of requests to enter the CS.  Ensures only one process at a time can access the CS  Separate handling of different CS’s Centralized Control of Distributed Mutual Exclusion L P2 P3 P1 CS 1. Request To enter CS 2. Grant token 3. Enter CS 4. Exit CS 5. Release Token

Lecture 7- 8 Centralized control of Distributed ME  Operations (token gives access to CS)  To enter a CS Send a request to L & wait for token.  On exiting the CS Send a message to the coord to release the token.  Upon receipt of a request, if no other process has the token, L replies with the token; otherwise, L queues the request.  Upon receipt of a release message L removes the oldest entry in the queue (if any) and replies with a token.  Features:  Safety, liveness and order are guaranteed  It takes 3 messages per entry + exit operation.  Client delay: one round trip time (request + grant)  Synchronization delay: one round trip time (release + grant)  The coordinator becomes performance bottleneck and single point of failure.

Lecture 7- 9  Processes are organized in a logical unidirectional ring: p i has a communication channel to p (i+1)mod (n+1).  Operations:  Only the process holding the token can enter the CS.  To enter the critical section, wait for the token.  To exit the CS, p i sends the token onto its neighbor.  If a process does not want to enter the CS when it receives the token, it forwards the token to the next neighbor. Token Ring Approach P0 P1 P2 P3 Pn Previous holder of token next holder of token current holder of token  Features:  Safety & liveness are guaranteed, but ordering is not.  Bandwidth: 1 message per exit  Client delay: 0 to (N+1) message transmissions.  Synchronization delay between one process’s exit from the CS and the next process’s entry is between 1 and N message transmissions.

Lecture Timestamp Approach: Ricart & Agrawala  Processes requiring entry to critical section multicast a request, and can enter it only when all other processes replied positively.  Messages requesting entry are of the form, where T is the sender’s timestamp (from a Lamport clock) and p i the sender’s identity (used to break ties in T).  state of a process can be wanted, held, released  p i to enter the CS  set state to wanted  multicast “request” to all processes (include timestamp).  wait until all processes send back “reply”  change state to held and enter the CS  On receipt of a request at p j :  if (state = held) or (state = wanted & (T j, p j )<(T i,p i )), enqueue request  else “reply” to p i  p i on exiting the CS  change state to release and “reply” to all queued requests.

Lecture Ricart and Agrawala’s algorithm On initialization state := RELEASED; To enter the section state := WANTED; Multicast request to all processes;request processing deferred here T := request’s timestamp; Wait until (number of replies received = (N – 1)); state := HELD; On receipt of a request at p j (i ≠ j) if (state = HELD or (state = WANTED and (T, p j ) < (T i, p i ))) then queue request from p i without replying; else reply immediately to p i ; end if To exit the critical section state := RELEASED; reply to any queued requests;

Lecture Ricart and Agrawala’s algorithm p 3 34 Reply p 1 p 2 Reply (T p2, p2) < (T p1, p1), (T p2, 34) < (T p1, 41) Hence enqueue request From p1

Lecture Timestamp Approach: Ricart & Agrawala  Features:  Safety, liveness, and ordering (causal) are guaranteed (why?)  Messages per entry operation  2(N-1) = (N-1) unicasts for the multicast request + (N-1) replies; » N messages if the underlying network supports multicast, – Messages per exist operation » N-1 unicast » 1 multicast if the underlying network supports multicast  Client delay:  one round-trip time  Synchronization delay:  one message transmission time.

Lecture Timestamp Approach: Maekawa’s Algorithm  Multicasts messages to a (voting) subset of nodes  Each process p i is associated with a voting set v i (of processes)  Each process belongs to its own voting set  The intersection of any two voting sets is not empty  Each voting set is of size K  Each process belongs to M other voting sets  To access at resource, p i requests permission from all other processes in its own voting set v i  Guarantees safety, not liveness (may deadlock)  Maekawa showed that K=M= O(  N) works best One way of doing this is to put nodes in a  N by  N matrix and take the union of row & column containing p i as its voting set. Example: N= 16, if we put 16 processes into 4x4 matrix, the voting set for P7 is V i (P7) = {P3, P5, P6, P7, P8, P11, P15}, where K = 2*4 – 1 = 2*  N – 1 = O(  N)

Lecture Maekawa’s algorithm – On initialization state := RELEASED; voted := FALSE; For p i to enter the critical section state := WANTED; Multicast request to all processes in V i ; Wait until (number of replies received = K); state := HELD; On receipt of a request from p i at p j if (state = HELD or voted = TRUE) then queue request from p i without replying; else send reply to p i ; voted := TRUE; end if For p i to exit the critical section state := RELEASED; Multicast release to all processes in V i ; On receipt of a release from p i at p j if (queue of requests is non-empty) then remove head of queue – from p k, say; send reply to p k ; voted := TRUE; else voted := FALSE; end if

Lecture Maekawa’s Algorithm - Analysis 2  N messages per entry,  N messages per exit –Better than Ricart and Agrawala’s (2(N-1) and N-1 messages) Client delay: –One round trip time Synchronization delay: –One round-trip time

Lecture Raymond’s Token-based Approach  Processes are organized as an un-rooted n-ary tree.  Each process has a variable HOLDER, which indicates the location of the token relative to the node itself.  Each process keeps a REQUEST_Q that holds the names of neighbors or itself that have sent a REQUEST, but have not yet been sent the token in reply.  REQUEST_Q HOLDER 8 = 3 HOLDER 3 = 1 HOLDER 1 = 1

Lecture Raymond’s Token-based Approach  To enter the CS  Enqueue self.  If a request has not been sent to HOLDER, send a request.  Upon receipt of a REQUEST message from neighbor x  If x is not in queue, enqueue x.  If self is a HOLDER and still in the CS, do nothing further.  If self is a HOLDER but exits the CS, then get the oldest requester (i.e., dequeue REQUEST_Q), set it to be the new HOLDER, and send token to the new HOLDER P8 requests entry to CS And P1 is in CS New HOLDER 1 = 3 New HOLDER 8 = 8 New HOLDER 3 = 8

Lecture Raymond’s Token-based Approach  Upon receipt of a token message  Dequeue REQUEST_Q and set the oldest requester to be HOLDER.  If HOLDER=self, then hold the token and enter the CS.  If HOLDER= some other process, send token to HOLDER. In addition, if the (remaining) REQUEST_Q is non-empty, send REQUEST to HOLDER as well.  On exiting the CS  If REQUEST_Q is empty, continue to hold token.  If REQUEST_Q is non-empty, then  dequeue REQUEST_Q and set the oldest requester to HOLDER, and send token to HOLDER.  In addition, if the (remaining) REQUEST_Q is non-empty, send REQUEST to HOLDER as well. Help other Processes access resource transitively

Lecture Example:Raymond’s Token-based Approach Initial State , , 6 3, , 6, , , Req. by P2 4. Req. by P6 5. P1 passes T to P3 6. P3 passes T to P , Req. by P7 7. P8 passes T to P3, to P6 9. P6 passes T to P3, to P1 2. Req. by P8

Lecture Analysis Bandwidth? Client delay? Synchronization delay? Try it at home, may be a question for next homework (or an exam question) Source: K. Raymond, “A Tree-based algorithm for distributed mutual exclusion”, ACM Transactions on Computer Systems (TOCS), 7(1): 61-77, 1989

Lecture Summary Mutual exclusion –Coordinator-based token –Token ring –Ricart and Agrawala’s timestamp algorithm –Maekawa’s algorithm –Raymond’s algorithm