Presentation is loading. Please wait.

Presentation is loading. Please wait.

Condition Variable Implementation (**with correction of signal**)

Similar presentations


Presentation on theme: "Condition Variable Implementation (**with correction of signal**)"— Presentation transcript:

1 Condition Variable Implementation (**with correction of signal**)
Each condition has a count, and a standard semaphore (with associated queue) initialized to 0 x.wait() { x.count++; if (next_count>0) signal(next); else signal(mutex); wait(x.sem); x.count--; } x.signal() { if (x.count >0){ next_count++; signal(x.sem); wait(next); next_count--; } Chapter 7

2 Monitor Implementation
Check two conditions to establish correctness of system: User processes must always make their calls on the monitor in a correct sequence. Must ensure that an uncooperative process does not ignore the mutual-exclusion gateway provided by the monitor, and try to access the shared resource directly, without using the access protocols. Chapter 7

3 Monitors: Final Comments
Note simpler, more structured code with monitors (compared to semaphores). See also Dining Philosophers example in text Under the hood, monitors are often implemented with semaphores. Monitors are a language concept, and are not commonly provided by current operating systems. Chapter 7

4 Conclusions on Synchronization Mechanisms
Several methods exist, each with variations. Most common: Semaphores, Monitors and Message passing. Monitors and Message passing are easiest to use, closest to programmer’s needs. Simpler mechanisms can be used to implement more sophisticated ones. No mechanism guarantees prevention of deadlocks, starvation, or busy waiting if used incorrectly but more sophisticated mechanisms make it easier to avoid them. Chapter 7

5 Midterm – Friday, July 4th
From Semaphores May 26th to clarification of implementation of Monitors today (June 27th) Following topic list highlights what was covered and cross-references with sections of the text where appropriate. BUT… you are responsible for all material covered in class (listed explicitly on the following slides or not) whether covered verbally and/or augmented by slides, handouts, or the book. Chapter 7

6 Midterm Topics Concurrency Semaphores (7.4):
Busy-waiting Blocking (counting and binary) Classic Problems of Synchronization (7.5) Producer Consumer Unbounded Buffer, Bounded Buffer Reader-Writers Dining Philosophers Monitors (7.7): Including underlying implementation w/ semaphores Chapter 7

7 Midterm Topics (cont.) Deadlocks (all of ch. 8): System Model
Deadlock Characterization Methods for Handling Deadlock Prevention Avoidance Detection Recovery Chapter 7

8 Midterm Topics (cont.) Interprocess communication (4.5)
Message Passing (4.5.1) Naming (4.5.2) Synchronization (4.5.3) Pipes Sockets (4.6.1) Chapter 7


Download ppt "Condition Variable Implementation (**with correction of signal**)"

Similar presentations


Ads by Google