Talk:Monitor (synchronization): Difference between revisions

Content deleted Content added
Tcpp (talk | contribs)
Line 21:
 
I believe the implementation given here is incorrect. If a thread calls wait() after signal() has been called it may be stuck indefinitely, since signal() increments the semaphore only enough times for threads already waiting. <small class="autosigned">—&nbsp;Preceding [[Wikipedia:Signatures|unsigned]] comment added by [[Special:Contributions/2601:647:5100:4C2:34BB:EEAA:46DD:66AD|2601:647:5100:4C2:34BB:EEAA:46DD:66AD]] ([[User talk:2601:647:5100:4C2:34BB:EEAA:46DD:66AD|talk]]) 21:54, 8 March 2016 (UTC)</small><!-- Template:Unsigned IP --> <!--Autosigned by SineBot-->
 
:No, it's correct because <code>signal()</code> is supposed to only wake up threads that are currently waiting. However, this implementation has another problem regarding the wait operation's atomicity, which is described in [https://www.microsoft.com/en-us/research/publication/implementing-condition-variables-with-semaphores/ Andrew D. Birrell's paper]. [[User:Tcpp|Tcpp]] ([[User talk:Tcpp|talk]]) 13:34, 18 May 2021 (UTC)
 
== Condition variable ==