Download presentation
Presentation is loading. Please wait.
1
Distributed Mutual Exclusion Béat Hirsbrunner References G. Coulouris, J. Dollimore and T. Kindberg "Distributed Systems: Concepts and Design", Ed. 4, Addison-Wesley 2005, Chap. 12.2 Beverly A. Sanders "The Information Structure of Distributed Mutual Exclusion Algorithms", ACM Transactions On Computer Systems, Vol. 5, No 3, August 1987, pp. 284-299 Distributed Systems Béat Hirsbrunner (UniFr), Peter Kropf (UniNe) and Pierre Kuonen (EiaFr) Summer Semester 2007, Lecture 2c, 30 March 2007
2
2 Mutual Exclusion Problem Four classical conditions to provide mutual exclusion 1) No two processes simultaneously in critical region 2) No assumptions made about speeds or numbers of CPUs 3) No process running outside its critical region may block another process 4) No process must wait forever to enter its critical region Critical Region (CR) Enter CR Leave CR time (1) Door is always open (1) (2) Door is closed or open (1)(2)(1)
3
3 Requirements ME1 (Safety) At most one process may execute in the critical section at any given point in time. ME2 (Liveness) Requests to enter or exit the critical section will eventually succeed. ME3 (–> Ordering) If request r1 to enter the critical section is issued before another request r2, i.e. r1 –> r2, then the requests will be served in the same order. Remark Requirement ME3 is specific for mutual exclusion algorithms in message-passing based distributed systems.
4
4 Performance Criteria P1. Bandwidth consumed (corresponds to number of messages sent). P2. Client delay at each entry and exit. P3. Throughput: Number of critical region accesses that the system allows. (Measured in terms of the synchronization delay between one process exiting the critical section and the next process entering)
5
5 Central Server Algorithm Properties : Satisfies ME1 and ME2, but not ME3 (network delays may reorder requests). Central server receives "Request token" if no process in critical section, request will be granted if process in critical section, request will be queued Central server receives "Release token" grant access to next process in queue, or wait for new requests if queue is empty Performance – Two messages per request, one per exit, exit does not delay process. – Performance and availability of server are the bottlenecks.
6
6 Ring-Based Algorithm logical, not necessarily physical link: every process p i has connection to process p (i+1) mod N token passes in one direction through the ring token arrival only process in posession of token may access critical region if no request upon arrival of token, or when exiting critical region, pass token on to neighbourg Properties : Satisfies ME1 and ME2, but not ME3. Performance Continuously network bandwidth consumption (except when a process is inside he critical section). Delay to enter the critical section: 0 to n messages. Exit the critical section: 1 message.
7
7 Ricart and Agrawala's Algorithm On initialization state := RELEASED; To enter the section state := WANTED; Multicast request to all processes; 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;
8
8 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 – {p i }; Wait until (number of replies received = (K – 1)); state := HELD; On receipt of a request from p i at p j (i 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 – {p i }; On receipt of a release from p i at p j (i 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
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.