[Mono-list] solution for Thread::Abort()

Fergus Henderson fjh@cs.mu.oz.au
Fri, 9 Aug 2002 20:02:30 +1000


On 09-Aug-2002, Piers Haken <piersh@friskit.com> wrote:
> Can someone summarize how the boehm GC handles multi-threaded applications

The Boehm GC uses a stop-the-world approach: when a thread decides
that it needs to do a garbage collection, it calls GC_stop_world(),
which suspends all the other threads.  This is done using by sending
signals to them using pthread_kill(), and waiting until they suspended.
The technique is essentially the same as the one mentioned in
<http://lists.ximian.com/archives/public/mono-list/2002-August/001393.html>,

Then, once all the threads have been suspended, the Boehm collector
goes ahead and does garbage collection.  In earlier versions,
this was done completely single-threaded; more recent versions
have a compilation option "-DPARALLEL_MARK" which lets the mark
phase of collection use multiple threads.  (This is documented at
<http://www.hpl.hp.com/personal/Hans_Boehm/gc/scale.html>.)

Finally, once collection is complete, the suspended threads are resumed
again.


In general, with this sort of approach, it is necessary to advance each
thread to a GC-safe point before starting a collection.  Since the Boehm
collector is conservative, every instruction is a GC-safe point, so this
step is not needed.  That makes things a bit easier.

-- 
Fergus Henderson <fjh@cs.mu.oz.au>  |  "I have always known that the pursuit
The University of Melbourne         |  of excellence is a lethal habit"
WWW: <http://www.cs.mu.oz.au/~fjh>  |     -- the last words of T. S. Garp.