[Gc] Attaching and dettaching existing threads

David Bakin d.bakin@comcast.net
Mon, 13 Oct 2003 23:21:54 -0700

On Windows a DLL does not get notified (via DLL_THREAD_ATTACH) of threads
existing before the DLL was loaded - except for the thread loading the DLL
(which call DLLMain with parameter DLL_PROCESS_ATTACH).  It also doesn't get
notified for each thread when the process (only for the thread that is
actually calling ExitProcess) or for threads that are TerminateThread'.

You can enumerate all threads in the system (!) via
CreateToolhelp32Snapshot(TH32CS_SNAPTHREAD,0) - searching for only those
threads in the GC process - I hate to think of how long that would take on a
heavily loaded system and there's no way to get just the threads of a given
(or current) process at the Win32 level.

-- Dave

----- Original Message ----- 
From: "Boehm, Hans" <hans_boehm@hp.com>
To: "'Thong (Tum) Nguyen'" <tum@veridicus.com>; <gc@napali.hpl.hp.com>
Sent: Monday, October 13, 2003 11:17 AM
Subject: RE: [Gc] Attaching and dettaching existing threads

> 3) This model doesn't handle threads that were running before the dynamic
> containing the GC was loaded.  (Actually, I suspect it does in the win32
GC-as-DLL case,
> since I would expect the library to be notified of all such threads.  But
it works
> nowhere else.)