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

Slides:



Advertisements
Similar presentations
CS 603 Process Synchronization: The Colored Ticket Algorithm February 13, 2002.
Advertisements

Mutual Exclusion – SW & HW By Oded Regev. Outline: Short review on the Bakery algorithm Short review on the Bakery algorithm Black & White Algorithm Black.
CIS 540 Principles of Embedded Computation Spring Instructor: Rajeev Alur
CSC321 Concurrent Programming: §3 The Mutual Exclusion Problem 1 Section 3 The Mutual Exclusion Problem.
Operating Systems: Sync
Ch. 7 Process Synchronization (1/2) I Background F Producer - Consumer process :  Compiler, Assembler, Loader, · · · · · · F Bounded buffer.
Process Synchronization Continued 7.2 The Critical-Section Problem.
6.852: Distributed Algorithms Spring, 2008 Class 13.
Mutual Exclusion By Shiran Mizrahi. Critical Section class Counter { private int value = 1; //counter starts at one public Counter(int c) { //constructor.
1 Chapter 2 Synchronization Algorithms and Concurrent Programming Gadi Taubenfeld © 2007 Synchronization Algorithms and Concurrent Programming Gadi Taubenfeld.
5.1 Silberschatz, Galvin and Gagne ©2009 Operating System Concepts with Java – 8 th Edition Chapter 5: CPU Scheduling.
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition, Chapter 6: Process Synchronization.
Multiprocessor Synchronization Algorithms ( ) Lecturer: Danny Hendler The Mutual Exclusion problem.
1 Operating Systems, 122 Practical Session 5, Synchronization 1.
Chair of Software Engineering Concurrent Object-Oriented Programming Prof. Dr. Bertrand Meyer Lecture 4: Mutual Exclusion.
Mutual Exclusion.
CH7 discussion-review Mahmoud Alhabbash. Q1 What is a Race Condition? How could we prevent that? – Race condition is the situation where several processes.
China’s Software Industry August 2006 Instructor: Hengming Zou, Ph.D.
Local-spin, Abortable Mutual Exclusion Joe Rideout.
Critical Section chapter3.
Chapter 3 The Critical Section Problem
1 Course Syllabus 1. Introduction - History; Views; Concepts; Structure 2. Process Management - Processes; State + Resources; Threads; Unix implementation.
CIS 540 Principles of Embedded Computation Spring Instructor: Rajeev Alur
CPSC 668Set 14: Simulations1 CPSC 668 Distributed Algorithms and Systems Spring 2008 Prof. Jennifer Welch.
CPSC 668Set 7: Mutual Exclusion with Read/Write Variables1 CPSC 668 Distributed Algorithms and Systems Fall 2009 Prof. Jennifer Welch.
1 Course Syllabus 1. Introduction - History; Views; Concepts; Structure 2. Process Management - Processes; State + Resources; Threads; Unix implementation.
1 Tuesday, June 20, 2006 "The box said that I needed to have Windows 98 or better... so I installed Linux." - LinuxNewbie.org.
Chapter 6: Process Synchronization. Outline Background Critical-Section Problem Peterson’s Solution Synchronization Hardware Semaphores Classic Problems.
Bakery Algorithm - Proof
Concurrency in Distributed Systems: Mutual exclusion.
Instructor: Umar KalimNUST Institute of Information Technology Operating Systems Process Synchronization.
Operating Systems CSE 411 CPU Management Oct Lecture 13 Instructor: Bhuvan Urgaonkar.
1 Lecture 9: Synchronization  concurrency examples and the need for synchronization  definition of mutual exclusion (MX)  programming solutions for.
The Critical Section Problem
28/10/1999POS-A1 The Synchronization Problem Synchronization problems occur because –multiple processes or threads want to share data; –the executions.
Process Synchronization Continued 7.2 Critical-Section Problem 7.3 Synchronization Hardware 7.4 Semaphores.
6.852: Distributed Algorithms Spring, 2008 Class 13.
THIRD PART Algorithms for Concurrent Distributed Systems: The Mutual Exclusion problem.
Silberschatz, Galvin and Gagne  Operating System Concepts Chapter 7: Process Synchronization Background The Critical-Section Problem Synchronization.
Silberschatz, Galvin and Gagne ©2013 Operating System Concepts Essentials – 9 th Edition Chapter 5: Process Synchronization.
Mutual Exclusion Using Atomic Registers Lecturer: Netanel Dahan Instructor: Prof. Yehuda Afek B.Sc. Seminar on Distributed Computation Tel-Aviv University.
1 Chapter 2 Synchronization Algorithms and Concurrent Programming Gadi Taubenfeld © 2014 Synchronization Algorithms and Concurrent Programming Synchronization.
CSCE 668 DISTRIBUTED ALGORITHMS AND SYSTEMS Spring 2014 Prof. Jennifer Welch CSCE 668 Set 8: More Mutex with Read/Write Variables 1.
1 Concurrent Processes. 2 Cooperating Processes  Operating systems allow for the creation and concurrent execution of multiple processes  concurrency.
Operating Systems CMPSC 473 Mutual Exclusion Lecture 11: October 5, 2010 Instructor: Bhuvan Urgaonkar.
Synchronicity Introduction to Operating Systems: Module 5.
Chapter 11 Resource Allocation by Mikhail Nesterenko “Distributed Algorithms” by Nancy A. Lynch.
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition Chapter 6: Process Synchronization.
6.852: Distributed Algorithms Spring, 2008 Class 14.
CIS 540 Principles of Embedded Computation Spring Instructor: Rajeev Alur
Homework-6 Questions : 2,10,15,22.
Chapter 10 Mutual Exclusion Presented by Yisong Jiang.
Bakery Algorithm - Proof
CSCE 668 DISTRIBUTED ALGORITHMS AND SYSTEMS
Chapter 6-7: Process Synchronization
CSCE 668 DISTRIBUTED ALGORITHMS AND SYSTEMS
Course Syllabus 1. Introduction - History; Views; Concepts; Structure
Lecture 20 Syed Mansoor Sarwar
Lecture 2 Part 2 Process Synchronization
Course Syllabus 1. Introduction - History; Views; Concepts; Structure
Multiprocessor Synchronization Algorithms ( )
Course Syllabus 1. Introduction - History; Views; Concepts; Structure
Chapter 10: Mutual Exclusion
Chapter 6: Synchronization Tools
Course Syllabus 1. Introduction - History; Views; Concepts; Structure
Course Syllabus 1. Introduction - History; Views; Concepts; Structure
CSE 542: Operating Systems
CSE 542: Operating Systems
Syllabus 1. Introduction - History; Views; Concepts; Structure
Presentation transcript:

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 Single-Writer Shared Register Algorithms The Bakery Algorithm Conclusion

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

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

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

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

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

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

Stronger Conditions Fairness  No lockouts or starvations  Kinds of fairness Low level fairness High level fairness

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

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

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

PetersonNP Algorithm

Is well formed Satisfies mutual exclusion Guarantees progress Lockout free

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

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

BurnsME Algorithm

Is well formed Guarantees mutual exclusion Guarantees progress

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

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

Bakery Algorithm

Is well formed Satisfies mutual exclusion Guarantees progress Guarantees lockout freedom

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

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

Questions?