Hi Ben,

Your fix works great in Cuis too, thank you! (Cuis also had this annoying
problem).

I spent a few hours at this, and I couldn't really understand the problem
with the old code. But yours makes perfect sense to me, and indeed it fixes
the problem.

One problem that remains is the use of AccessProtect variable. The other
users of this "mutex semaphore" assume it gives them exclusive access to
the state. This is no longer the case! It is best to completly remove the
AccessProtect variable, and avoid any risk of deadlock. To do this, in
Cuis, I made #shutDown and #startUp to call #stopTimerEventLoop and
#startTimerEventLoop. I also removed DelaySuspended. It seems to work ok,
and I suggest doing the same for Pharo (and Squeak).

Cheers,
Juan Vuletich

Quoting Ben Coman <[email protected]>:

... Anyway, the delay scheduling code seemed more like a
producer/consumer signaling problem than a shared resource mutal
exclusion problem, so I rewrote it like the former and fixes the problem
without causing any *obvious* problems.  However I lack experience here
and it could definitely use some review.  Can you take the attached zip
file and...

1. File in "Delay class-new delay code part 1.st"
    Defines #enableNewDelayCode and #enableNewDelayCode:
    Manually define the referenced class variables

2. File in "Delay class-new delay code part 2.st"
     Modifies #handleTimerEvent, guarded by enableNewDelayCode

3. File in "Delay-new delay code part 3.st"
    Modifies #schedule and #unschedule, guarded by enableNewDelayCode

4. File in "BackgroundWorkDisplayMorph.st"

5. Save checkpoint Image to return to between trials.

6. Open System Browser on BackgroundWorkDisplayMorph>>initialize
   
Trial 1.
BackgroundWorkDisplayMorph new openInWorld.

Trial 2.
Delay enableNewDelayCode: true.
BackgroundWorkDisplayMorph new openInWorld.

If if its deemed worthwhile, I'll open a ticket to track this more
formally.  One thing needed is to considered performance impact, I
haven't so far.

cheers -ben

[1] http://www.barrgroup.com/Embedded-Systems/How-To/RTOS-Mutex-Semaphore
[2] http://nerdfortress.com/2011/02/18/you-say-semaphore-i-say-mutex/

Reply via email to