Presentation is loading. Please wait.

Presentation is loading. Please wait.

MUTUAL EXCLUSION AND QUORUMS CS 2711. Distributed Mutual Exclusion Given a set of processes and a single resource, develop a protocol to ensure exclusive.

Similar presentations


Presentation on theme: "MUTUAL EXCLUSION AND QUORUMS CS 2711. Distributed Mutual Exclusion Given a set of processes and a single resource, develop a protocol to ensure exclusive."— Presentation transcript:

1 MUTUAL EXCLUSION AND QUORUMS CS 2711

2 Distributed Mutual Exclusion Given a set of processes and a single resource, develop a protocol to ensure exclusive access to the resource by a single process at a time. This is a fundamental operation in operating systems, and is generalized to locking in databases. CS 2712

3 Centralized Solution Choose a special coordinator site, coord. Coord maintains a queue of pending requests. Protocol: – Process send request to coord. – If no other request, coord sends back reply. Otherwise, put request in queue – On receipt of reply, process accesses resource. – Once done, process sends release to coord. – On receipt of release, coord checks queue for any pending requests. CS 2713

4 Centralized Solution P0P0 C request(R) reply(R) release(R) P1P1 P2P2 request(R) Queue P1P1 request(R) P2P2 reply(R) CS 2714 thanks paul krzyzanowski rutgers

5 Distributed Solution Instead of a central coordinator, all processes collectively Use similar approach: – Process sends request to all processes and puts request in local queue. – On receipt of request, process sends back reply. – Process accesses resource On receipt of all replies Own request at head of queue – Once done, process sends release to all processes. – On receipt of release, process removes request CS 2715

6 Distributed Solution Does this work (Lamport original solution)? Need to order queues so they are identical: – Use logical Lamport time + proc id to break ties. – FIFO channels Requests are executed in causal order. Ricart and Agrawala’s optmization: – If a process also wants resource, it replies only if request has lower timestamp (higher priority). – No need for FIFO CS 2716

7 Quorums What if there are failures? Do we need to communicate with ALL processes? Any two requests should have a common process to act as an arbitrator. Let process p i (p j )request permission from V i (V j ), then – V i ⋂ V j ≠ ϕ. V i is called a quorum. Basic protocol still works (basically think locking), but: Deadlock CS 2717

8 Quorums Given n processes: 2|V i | >n, ie, In general, majority, ie ⌈ (n/2) ⌉. [Gifford 79] CS 2718

9 Studying the Sizes of Quorums Can we have quorums of sizes LESS than majority? Yes, but we need to set up some basic ground rules. CS 2719

10 Maekawa’s Mutual Exclusion Assume process p i gets permission from quorum Q i and there are N processes. 1.Q i contains p i. 2.Equal Effort: |Q 1 |=|Q 2 |=…….|Q n |= K 3.Equal Responsibility: Every process is included in M quorums only. CS 27110

11 Minimality Result Each member of Q i is in M-1 other quorums. Max number of quorums: K(M-1) +1 Since # of quorums = # of processes N = K(M-1) +1 …………………..(1) N= (# of elements)/(# duplicates of elements) N= K*N/M  K=M ………… (2) From (1) and (2): N= K(K-1) + 1 Hence K= O( √ (N)) CS 27111

12 Quorum Sizes Finite Projective Plane Theory for N points ensure quorums of size √ (n). Easier, grid structure and any row and column. CS 27112

13 Quorum Sizes CS 27113

14 Tree Structure CS 27114 1 3 7 6 2 54

15 Tree Quorum Algorithm A path is a sequence of nodes such that each node is the parent of the next one in sequence. 1.Select a path from root to leaf. 2.If successful  this is the quorum. 3.O.W.  for each inaccessible node, pick two paths from 2 children to leaves. 4.Repeat recursively for all inaccessible nodes. Correctness Proof: By Induction. CS 27115

16 Tree Quorum Sizes Best case: log(n). Worst case: n/2 CS 27116

17 General Quorums In a database context, we have read and write operations. Hence, read quorums, Q r, and write quorums, Q w. Simple generalization: – Q r ⋂ Q w ≠ϕ, Q w ⋂ Q w ≠ϕ – Q r + Q w > n and 2 Q w > n CS 27117

18 Basic Concepts up to now Happens before and causality Logical (Lamport) Clocks Vector Clocks Mutual Exclusion Quorums CS 27118


Download ppt "MUTUAL EXCLUSION AND QUORUMS CS 2711. Distributed Mutual Exclusion Given a set of processes and a single resource, develop a protocol to ensure exclusive."

Similar presentations


Ads by Google