Tom Pledger writes:
 > [...]
 > 
 > Something along these lines:

But without the bug and the eccentricities.  :-(

 > [...]
 >         wasDown2 <- sag flag2

This just moved the deadlock.  Instead of doing a busy wait for a
non-sagging flag2, we must put flag1 back up and try again from the
beginning of lowerFlags.

 >         _ <- takeMVar flag1             -- We know flag1 is now sagging

Or:        takeMVar flag1

 >         if wasDown2 then putMVar flag1 Up else do
 >           _ <- takeMVar flag2           -- We know flag2 is now sagging
 >           putMVar flag2 Down

Or:        if ...
             swapMVar flag2 Down

Regards,
Tom

Reply via email to