View
213
Download
0
Tags:
Embed Size (px)
Citation preview
2
Critical Regions (1)
Four conditions to provide mutual exclusion1. 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
4
Mutual Exclusion with Busy Waiting (1)
Proposed solution to critical region problem(a) Process 0. (b) Process 1.
6
Mutual Exclusion with Busy Waiting (3)
Entering and leaving a critical region using the
TSL instruction
8
What is a Semaphore?
•A mechanism that provides concurrency among processes.
•Facilitates synchronization among processes.
•Usually implemented with a struct, including an int as well as other information fields, and a queue to ensure mutual exclusion to a shared resource.
•Requires two operations (functions):
•sleep() or down()
•wakeup() or up()
•A new type of variable that saves the number of pending wakeups.