Hello.
Here is Monitor code:
Now look at Semaphore comment and implementation:
What you think? Is my investigation right? I look at users of Monitor. Most time it is used like Mutex. Only #critical: method is used. So Monitor can be replaced by Mutex at that places. And possible problem will be fixed. SharedQueue is classic example for Monitor usage. Interesting is anybody got problems with it? |
You may have a point there. Although the monitor uses a Semaphore #forMutualExclusion, which is a semaphore with one signal. So the case where the semaphore gets signalled without #wait is less likely I think. What I don’t quite understand is why Monitor doesn’t use Semaphore>>critical:. If it did that, then there wouldn’t be a problem. The problem only exists because #wait and #signal are explicitly sent by the monitor. |
2016-01-05 12:59 GMT+01:00 Max Leske <[hidden email]>:
No. It has no relation to incorrect scenarios of semaphore signalling. #forMutualExclusion just make semaphore free to use. So first caller of #wait will grab lock. And others will wait. Two times signalled semaphore will allow two critical sections be performed simultaneously which should not happen |
|
In reply to this post by Max Leske
2016-01-05 12:59 GMT+01:00 Max Leske <[hidden email]>: What I don’t quite understand is why Monitor doesn’t use Semaphore>>critical:. If it did that, then there wouldn’t be a problem. The problem only exists because #wait and #signal are explicitly sent by the monitor. Monitor is reentral which means that two recursive critical sections in same process should not be blocked. This logic implemented in #enter and #exit methods |
I should start using my head again. This is a new year… :) Thanks Denis. |
:) 5 янв. 2016 г. 2:18 PM пользователь "Max Leske" <[hidden email]> написал:
|
Free forum by Nabble | Edit this page |