[Gc] Fix for threaded gc on MacOSX

Brian Alliet brian@brianweb.net
Thu, 11 Dec 2003 09:40:04 -0500 (EST)

Andrew Begel said:
> In my testing, using the GC in a multi-threaded situation where my code
> was not in control of initializing the GC from the main thread before
> other threads were initialized (basically every other situation where
> GC-enabled code executes from arbitrary threads at any point during
> execution), it seems to work great.

If you have threads that aren't using the GC's pthread_create function
then there would be a race condition when you call task_threads. Another
thread could potentially be created after this call. However, as long as
all threads using the GC were created using the GC's pthread_create this
should work because GC_pthread_create acquires the lock.

FindTopOfStack kind of makes me nervous too. As long as the compiler
doesn't do anything strange it should work fine though.

I think we can probably fix the problem where the gc can't be initialized
from a non-main thread without changing the stopping code so much. I don't
think using mach's task_threads really buys us much. The GC needs the
GC_thread bookkeeping information for more than just stopping threads so
thats going to have to stick around regardless of how we're stopping the