guile-user
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Guile, pthreads and garbage collection


From: Michael J. Barillier
Subject: Guile, pthreads and garbage collection
Date: 13 May 2002 09:55:10 -0600
User-agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.1

I'm designing an app with a background thread that access Guile SMOBs.
If I'm running code in a pthread, can I trust Guile not to garbage
collect a value while I'm accessing the content of the data structure
under the SMOB?

In particular, suppose I have a (Guile/Scheme) symbol whose value I'm
squirreling away in a global SCM (C) variable.  If the symbol gets
garbage collected in the main thread (no more active references) but
in the background thread I'm busy working with the C data structure,
how can I protect that structure from the free_foosmob() (or whatever)
call?  I've tried to come up with some solutions involving mutexes,
but it gets real hokey real fast.  From reading the Guile docs, it
appears that Guile scans the stack and marks any SCMs it finds on the
stack.  Unfortunately, in my case, the values I'm working with are
stored in a dynamically sized buffer--does the garbage collector also
run through the heap?  (This seems kinda expensive ...)

Or, am I worrying needlessly about something that will never happen?

Suggestions appreciated--thanks.

-- 
Michael J. Barillier
(let ((n "blackwolf") (h "pcisys.net")) (concatenate 'string n "@" h))
GnuPG public key ID: 0x35E54973
Fingerprint: EDB9 4FBC 4D0B 070C C0E3 2EE4 D822 78CE 35E5 4973
Knowledge shared is power lost. -- Aleister Crowley



reply via email to

[Prev in Thread] Current Thread [Next in Thread]