Jump to content
Urch Forums

Monitors


ambreenjava

Recommended Posts

Moders Operating System By Andrew Tanenbaum

 

Synchronization within monitors uses condition variables and 2 special operations, WAIT and SIGNAL. A more general form of synchronization would be to have a single primitive, WAITUNTIL that had an arbitrary boolean predicate as parameter. Thus one could say

 

WAITUNTIL x

 

This approach though simple is not used. Why?

Link to comment
Share on other sites

One thing I guess thats wrong with WAITUNTIL is it wont block processes. The process will contine to check in loop, rather than sleeping and be awaked by the other process.

 

Lets say we write a producer consumer problem using WAITUNTIL

 

monitor ProducerConsumer

integer count;

 

procedure enter;

begin

if count = N then WAITUNTIL (count,EMPTY);

enter_item;

count := count + 1;

end

 

procedure remove;

begin

if count = 0 then WAITUNTIL(count,FULL);

remove_item;

count := count -1;

 

end;

 

end monitor;

Is there a race condition or a dead lock involved?

 

 

 

 

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...