[ENH] RecursiveMutex (disregard RecursionLock)

Stephan Rudlof squeak-dev at lists.squeakfoundation.org
Sat Sep 21 19:20:29 UTC 2002


Lex Spoon wrote:
> Stephan Rudlof <sr at evolgo.de> wrote:
> 
> 
>>> I'm not convinced it is
>>>thread-safe, but what the heck.
>>
>>You could shelter it by another Sema ;-)
>>
>>
>>>Maybe it's as thread-safe as the
>>>operation inherently is, anyway.
>>
>>Too short to understand your possible problems.
> 
> 
> What I mean is, why bother protecting something if the definition of the
> operation has inherent race conditions.  


> For example, assume that some
> other thread is lurking in the background ready to signal the semaphore
> at the worst possible time -- does it matter if we make them wait to the
> end of the method?

The other thread signals; if it has been
- before zeroing the excessSignals instVar,
  it is 0 after finishing the >>initSignals method;
- after zeroing the excessSignals instVar,
  it is 1.

> To make things harder, also imagine that multiple
> processes are watching the state of the semaphore, and that some of them
> might be suspended at the time.

You could of course zeroing it
- by sheltering the call of the method with another sema,
- with high process priority to prevent interrupting.

Greetings,

Stephan

> 
> I don't know.  I suspect it doesn't matter, but I haven't really thought
> it through completely.
> 
> 
> Lex
> 
> 


-- 
Stephan Rudlof (sr at evolgo.de)
   "Genius doesn't work on an assembly line basis.
    You can't simply say, 'Today I will be brilliant.'"
    -- Kirk, "The Ultimate Computer", stardate 4731.3




More information about the Squeak-dev mailing list