Presentation is loading. Please wait.

Presentation is loading. Please wait.

An object-based synchronization mechanism.

Similar presentations


Presentation on theme: "An object-based synchronization mechanism."— Presentation transcript:

1 An object-based synchronization mechanism.
Hoare’s Monitor Model An object-based synchronization mechanism. CS 5204 Fall 00

2 Condition Synchronization
Mutual exclusion is insufficient to guarantee that operations only happen when the system is in a proper “state” for the operation to be done without loss of safety A condition on the state of the system must be associated with the operation in such a way that the operation is only attempted when the condition is true CS 5204 Fall 00

3 Condition Synchronization
Examples: Producer­Consumer problem produce only when buffer is not full consume only when buffer is not empty Readers­Writer problem readers may read if the only other operation in progress is another read operation writers may write if there is no other operation in progress of either kind Evaluating the condition requires that the state of the system not change during the condition's evaluation ==> mutual exclusion during the evaluation CS 5204 Fall 00

4 Hoare's Monitor Model acquire lock monitor call release procedure/
return lock acquire release call monitor procedure/ method CS 5204 Fall 00

5 Hoare's Monitor Model lock acquire release call condition queue
C.wait( ) lock acquire release call condition queue CS 5204 Fall 00

6 Hoare's Monitor Model C.wait( ) lock acquire release call
condition queue urgent-queue C.signal( ) notify CS 5204 Fall 00

7 Hoare's Monitor Model Lock C-queue call C.wait( ) return C.signal( )
urgent-queue C.signal( ) notify call CS 5204 Fall 00

8 Hoare's Monitor Model monitor BoundedCounter begin
condition belowMax, aboveMin; integer value; constant MAX=100, MIN=0; void value() begin return value; end void inc() if (value == MAX) belowMax.wait(); value = value + 1; if (value == MIN+1) aboveMin.signal(); return; end void dec() if(value == MIN) aboveMin.wait(); value = value ­ 1; if(value == MAX­1) belowMax.signal(); value = MIN; CS 5204 Fall 00


Download ppt "An object-based synchronization mechanism."

Similar presentations


Ads by Google