ambreenjava Posted September 16, 2003 Share Posted September 16, 2003 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? Quote Link to comment Share on other sites More sharing options...
ambreenjava Posted September 16, 2003 Author Share Posted September 16, 2003 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? Quote Link to comment Share on other sites More sharing options...
rafi_dery Posted September 17, 2003 Share Posted September 17, 2003 ambreenjava, I agree with you. Since the process won't block, but rather check for the condition, it will continue to occupy the monitor, avoiding other processes from entering the monitor. a deadlock occurs. Quote Link to comment Share on other sites More sharing options...
ambreenjava Posted September 17, 2003 Author Share Posted September 17, 2003 O yeah, since only one process can be in a monitor at a time. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.