[Gc] Scanning the System Stack

Andrew Begel abegel at eecs.berkeley.edu
Tue Mar 30 03:52:44 PST 2004

There is no cross-platform way to do this when there are threads, but 
if you are single threaded, usually the stack starts at a known 
location (it's in include/private/gcconfig.h), and by knowing the ABI 
of the processor/OS you can find the current value of the stack 
pointer. From there, you loop through each address on the stack, adding 
it to the GC with GC_push_all_stacks(loaddr, hiaddr).

With pthread-based threaded execution, each stack start could be at a 
completely unknown location, specifiable at pthread_create(), but not 
retrievable afterwards. Without this information (except on MacOSX) you 
can't scan the stack because you don't know where it starts.


On Mar 29, 2004, at 10:42 PM, wlight at weatherlight.com wrote:

> I apologize if I'm sending this email off topic or out of turn, but I 
> am new to this mailing list.
> I'm a graduate student at the University of Florida.  I'm presently 
> working on an independent study of garbage collection, and my final 
> project for the independent study is to be the implementation of a 
> garbage collection library in C that should be able to run on, at a 
> minimum, Solaris 8 for a SPARC or GNU/Linux for an Intel.  I've got a 
> lot of design decisions already made, but one thing is still evading 
> me- how do I scan the system stack and the registers?  I'm certain 
> there's a reasonably portable way to do this, but I can't figure it 
> out.  If anyone could send me a pointer or two on this, I'd be deeply 
> appreciative.
> I've downloaded the source code for the Boehm-Demers-Weiser collector, 
> hoping to find it in there, but I'm having trouble really working out 
> the source code in my head (most likely because so much of it seems to 
> be there to support various systems).
> --
> Rhett.
> _______________________________________________
> Gc mailing list
> Gc at linux.hpl.hp.com
> https://www.hpl.hp.com/hosted/linux/mail-archives/gc/

More information about the Gc mailing list