The HyperNews Linux KHG Discussion Pages

Question: Porting GC: Difficulties with pthreads

Forum: The Linux Kernel Hackers' Guide
Date: Fri, 17 Jul 1998 00:34:11 GMT
From: Talin <>

I'm attempting to get Hans Boehm's gc to run under Linux. (GC is a conservative, incremental, generational garbage collector for C and C++ programs). Apparently it has been ported to older versions of Linux, but the port appears broken. Searching around the web I notice that one or two other people have attempted to get this thing working without success. It's tantalizing because the bloody thing almost works. One major problem has to do with pthread support. GC needs to be able to stop a thread an examine it's stack for potential pointers, and there's no defined way in the pthreads API to do this. On SunOS, gc uses the /proc primitives to accomplish this task, unfortunately the Linux /proc lacks the ability to stop a process. Under Irix, it uses an evil hack -- it sends a signal to the pthread, and has the pthread wait on a condition variable inside the signal handler! Needless to say, this method is to be avoided if at all possible. Unfortunately, the author of gc says that this is unavoidable due to the limitations of the pthreads API. Does anyone have any ideas for how to go about suspending a thread and getting a copy of it's register set under Linux?