GC interuptable?

chrisj a at b.c
Sat Dec 16 07:15:39 PST 2006

"Sean Kelly" <sean at f4.ca> wrote in message 
news:elvfpr$1l8j$1 at digitaldaemon.com...
> chrisj wrote:
>> Can a low level thread interupt the GC and run ok as long as it doesnt 
>> use any GC related features? (Only referances memory not from the GC pool 
>> and such like)
> Are you asking whether it's safe to suspend the GC during a cleanup and 
> then go do something else?  If so, then my answer is a very tenative 
> "yes."  The GC suspends all threads it knows about during a collection 
> (ie. all instances of std.thread.Thread) so each of these threads is 
> frozen at some point of execution.  They could own mutexes, etc.  So any 
> operation that may involve shared state information risks deadlocking the 
> app.  In short, yes it's possible but you need to be very careful :-)

Say you have a soundcard in/out or somthing like.. which gets called via a 
callback from the driver or from windows, or even from another application. 
So the thread is not one actualy created by the D app... can the callback 
run as long as it doesnt use any features that will affect the GCed memory 
pool? Actually from what you say above it seems the GC cannot stop a 
callback from a thread it didnt create.. so the only option would be to make 
sure such a callback didnt affect the GC?



More information about the Digitalmars-d mailing list