[Gc] Darwin mach threads vs pthreads
abegel at eecs.berkeley.edu
Mon Jun 27 08:53:12 PDT 2005
With the GC, pthreads have to be intercepted at pthread_create() time
(with wrapped functions) in order to determine their stack bounds.
This is a problem if you cannot guarantee that the GC loads before
any other library in your application (e.g. GC is loaded by a plugin
module that you write, but not by the main application), you may miss
a pthread_create() call, and thus miss one of the threads when you
need to stop the world and trace the stack. Since on Darwin, all
pthreads are implemented with Mach threads, you can use the kernel
APIs for iterating through mach threads to find all threads that
currently exist in the process without having intercepted them first.
Then, since we don't know the stack bounds of the Mach threads, we
assume they follow the Darwin PPC ABI (as documented by Apple), which
is the case for any gcc or Java-compiled thread, and walk the stack
up to its stack top, stack frame by stack frame.
This is all explained in the GC README for Darwin.
On Jun 27, 2005, at 5:55 AM, Stephane Epardaud wrote:
> While porting Lurc to MacOSX, I'm currently compiling the GC 7.0a3
> on MacOSX and
> I have questions regarding darwin_stop_world. I compile with
> --enable-threads=pthreads and that gets me pthread_support.c, but
> it also
> defines GC_DARWIN_THREADS, which gets me darwin_stop_world instead of
> pthread_stop_world. Why is that ?
> In pthread_support, the GC manages the list of threads itself, and
> even has a
> mapping of pthread->mach-thread, whereas darwin_stop_world doesn't
> use anything
> pthread. Besides, the way I see it, pthread_stop_world would also
> work for
> MacOSX, since everything in there is pthread.
> I don't understand the need to delve into mach threads if pthreads
> are supported
> on the platform. What is the reason for that (I'm sure there must
> be a good one,
> but I haven't figured it out) ?
> Which leads me to the next question, why have a mapping of pthread-
> in pthread_support.c, I cannot see where it is used ?
> It seems to me the darwin_stop_world works for both mach-threads
> and pthreads on
> MacOSX, whereas pthread_stop_world only for pthreads, but then what
> use is there
> to the whole pthread_support functions for wrapping pthreads (maybe
> they aren't
> even wrapped on darwin?) ?
> Sorry for all these questions, but really I'm confused as to how to
> Lurc on MacOSX....
> Thanks for the help.
> Gc mailing list
> Gc at linux.hpl.hp.com
More information about the Gc