Thread overview
Semaphores and the GC.
Mar 31, 2006
Dave
Mar 31, 2006
Frank Benoit
Mar 31, 2006
Sean Kelly
March 31, 2006
Both windows and linux semaphores will not work correctly in the presence of the GC when it 'stops and restarts' the world (or at least I've not been able to get something working). The problem appears to be from pausing and/or resuming threads.

I've tried all of native POSIX semaphores and pthread mutex/conditions on Linux, and Windows API Semaphores. They all work up and until a GC happens or threads are paused and resumed in some other way.

Anyone out there have any ideas on how to implement POSIX semaphore-like functionality that will work w/ the GC?

Thanks,

- Dave


March 31, 2006
On linux, if you use semaphores.
The GC sends SIGUSR1 & SIGUSR2 to all threads for pausing and resuming.
The semaphores will wake up with error EINTR. You only have to check for
that, and wait again.
March 31, 2006
Frank Benoit wrote:
> On linux, if you use semaphores.
> The GC sends SIGUSR1 & SIGUSR2 to all threads for pausing and resuming.
> The semaphores will wake up with error EINTR. You only have to check for
> that, and wait again.

Sounds like a good reason to provide a wrapper for semaphores in D.


Sean