www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Semaphores and the GC.

reply Dave <Dave_member pathlink.com> writes:
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
Mar 31 2006
parent reply Frank Benoit <frank nix.de> writes:
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.
Mar 31 2006
parent Sean Kelly <sean f4.ca> writes:
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
Mar 31 2006