Hmph, this didn't make the through the first time, it seems. (Fix went
in as 18.104.22.168)
---------- Forwarded message ----------
From: Nikodemus Siivola <nikodemus@...>
Date: Fri, Sep 19, 2008 at 3:40 PM
Subject: Re: [Sbcl-devel] broken semaphores or broken test?
To: Kalyanov Dmitry <kalyanov.dmitry@...>
On Thu, Sep 18, 2008 at 3:39 PM, Kalyanov Dmitry
My problem is a bug in our semaphore implementation after all.
Wakeups happen if the semaphore was at 0 prior to signal-semaphore.
Consider the case where you have multiple waiters on a semaphore, and
another thread doing signal-semaphore with increment of 1.
T3 signal-semaphore, wakes up 1 thread
T1 wakes up, but doesn't manage to decrement the counter during its timeslice
T3 signal-semaphore -- counter already 1, no wakeup
T1 decrements, returns from wait
...T2 is never woken up even though the semaphore is at 1. Eugh. We
need to keep track of sleepers -- I have a fix which I'm committing
> I noticed similar problem (semaphores kept losing signals). Wrapping
> sb-thread:signal-semaphore and sb-thread:wait-on-semaphore inside
> (with-interrupts (allow-with-interrupts ...)) prevented this from happening.
> (Noted this in src/code/thread.lisp)
Do you have a test-case for this? Was WITH-TIMEOUT involved?