1 / 26

Mutual Exclusion

Mutual Exclusion. Presented by: Rohan Sen (Distributed Algorithms Ch. 10) . Topics that will be covered. Overview and problem statement Dijkstra’s Mutual Exclusion Algorithm Stronger Conditions for Mutual Exclusion Algorithms Lockout-free Mutual Exclusion Algorithms

nile
Télécharger la présentation

Mutual Exclusion

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Mutual Exclusion Presented by: Rohan Sen (Distributed Algorithms Ch. 10)

  2. Topics that will be covered • Overview and problem statement • Dijkstra’s Mutual Exclusion Algorithm • Stronger Conditions for Mutual Exclusion Algorithms • Lockout-free Mutual Exclusion Algorithms • Single-Writer Shared Register Algorithms • The Bakery Algorithm • Conclusion

  3. Overview • The shared memory model • Every process is a kind of state machine • Set of states • Three kinds of actions: input, output, internal • All communication via the shared memory • Exists a transition relation for all states • System is input-enabled • Not output and internal enabled • Locality restrictions • Restrictions on shared variable operations

  4. Allocation of single, indivisible, non-shareable resource among n users Steps by a user Trying protocol Critical region Exit protocol Remainder (non-critical region) The problem U try crit exit rem External interface of a user

  5. The problem (contd.) • A shared memory system solves the mutual exclusion problem when the following conditions are satisfied: • Well-formedness • Mutual exclusion • Progress

  6. Dijkstra’s Mutual Exclusion Alg. • Concept • Use a two stage flag to indicate what stage of processing a user is in • Ensure mutual exclusion by ensuring that only one flag at a time has a value to let it into the critical region

  7. Dijkstra’s Mutual Exclusion Alg. Shared Variables • turn rd / wr by all processes, intially arbitrary • flag(i) rd by all / wr by I, initially 0

  8. Dijkstra’s Mutual Exclusion Alg.

  9. Dijkstra’s Mutual Exclusion Alg. • Guarantees well-formedness • Per inspection of the code • Satisfies mutual exclusion • By status of flag • Guarantees progress • More complex proof

  10. Stronger Conditions • Fairness • No lockouts or starvations • Kinds of fairness • Low level fairness • High level fairness

  11. Stronger Conditions (contd.) • Lockout freedom • Any user that reaches T eventually enters C • Any user that reaches E eventually enters R • Time bound • If each user returns resource within time c and each step is at most l, then you enter C at most b = f(l,c)after entering T • Similarly, you enter R at most b = f(l,c)after entering E. • Number of bypasses

  12. PetersonNP Algorithm • Concept • There are k levels • At each level eliminate one user • n – k processes can win at level k • Only one process can win at level n – 1, yielding mutual exclusion

  13. PetersonNP Algorithm Shared variables • turn(k) rd / wr by all, initially arbitrary • flag(i) rd by all j ≠ i / wr by I, initially 0

  14. PetersonNP Algorithm

  15. PetersonNP Algorithm • Is well formed • Satisfies mutual exclusion • Guarantees progress • Lockout free

  16. Alg. Using Single Writer Shared Registers (BurnsME Algorithm) • Concept • Check if anyone else is trying to get a lock • Lay claim on the lock • Check again • Proceed

  17. BurnsME Algorithm • Shared variables • flag(i) wr by i / rd by all j ≠ I, initially 0

  18. BurnsME Algorithm

  19. BurnsME Algorithm • Is well formed • Guarantees mutual exclusion • Guarantees progress

  20. Bakery Algorithm • Concept • FIFO after a wait-free doorway • Doorway is: • Everyone picks a number • Waits for everyone to finish • Break ties and enter critical zone

  21. Bakery Algorithm • Shared variables choosng(i) wr by i / rd by all j ≠ I, initially 0 number(i) wr by i / rd by all j ≠ I, initially 0

  22. Bakery Algorithm

  23. Bakery Algorithm • Is well formed • Satisfies mutual exclusion • Guarantees progress • Guarantees lockout freedom

  24. Lower bound on # registers • Cannot solve mutual exclusion with <n shared variables • Single writer shared variables • Multi writer shared variables

  25. Conclusion • Mutual exclusion: One at a time access to a shared resource • Mutual exclusion w/o fairness • Mutual exclusion w/ fairness • Minimizing the number of registers

  26. Questions?

More Related