From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: Mikael Djurfeldt Newsgroups: gmane.lisp.guile.devel Subject: Re: hacking on 1.7 threads Date: Sun, 24 Oct 2004 11:29:06 +0200 Sender: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Message-ID: References: <2bc5f82104101906465a92d975@mail.gmail.com> <2bc5f821041023165523f40bc2@mail.gmail.com> Reply-To: djurfeldt@nada.kth.se NNTP-Posting-Host: deer.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: sea.gmane.org 1098610247 22371 80.91.229.6 (24 Oct 2004 09:30:47 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Sun, 24 Oct 2004 09:30:47 +0000 (UTC) Cc: djurfeldt@nada.kth.se, guile-devel@gnu.org Original-X-From: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Sun Oct 24 11:30:37 2004 Return-path: Original-Received: from lists.gnu.org ([199.232.76.165]) by deer.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 1CLehw-00085n-00 for ; Sun, 24 Oct 2004 11:30:36 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.33) id 1CLepX-0007YA-BE for guile-devel@m.gmane.org; Sun, 24 Oct 2004 05:38:27 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.33) id 1CLepA-0007Wl-Jf for guile-devel@gnu.org; Sun, 24 Oct 2004 05:38:04 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.33) id 1CLep9-0007Ve-4m for guile-devel@gnu.org; Sun, 24 Oct 2004 05:38:03 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.33) id 1CLep8-0007Uf-IM for guile-devel@gnu.org; Sun, 24 Oct 2004 05:38:02 -0400 Original-Received: from [213.212.20.77] (helo=kvast.blakulla.net) by monty-python.gnu.org with esmtp (Exim 4.34) id 1CLegh-0004bJ-Tm for guile-devel@gnu.org; Sun, 24 Oct 2004 05:29:20 -0400 Original-Received: from mamaliga.blakulla.net ([213.212.21.241] helo=witch) by kvast.blakulla.net with esmtp (Exim 3.36 #1 (Debian)) id 1CLegV-0005oO-00; Sun, 24 Oct 2004 11:29:07 +0200 Original-Received: from mdj by witch with local (Exim 4.34) id 1CLegU-0000x7-Sv; Sun, 24 Oct 2004 11:29:06 +0200 Original-To: Julian Graham In-Reply-To: <2bc5f821041023165523f40bc2@mail.gmail.com> (Julian Graham's message of "Sat, 23 Oct 2004 19:55:57 -0400") User-Agent: Gnus/5.1006 (Gnus v5.10.6) Emacs/21.3 (gnu/linux) X-BeenThere: guile-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Developers list for Guile, the GNU extensibility library" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Xref: main.gmane.org gmane.lisp.guile.devel:4289 X-Report-Spam: http://spam.gmane.org/gmane.lisp.guile.devel:4289 Julian Graham writes: > That is, if I'm storing a list SCM in an scm_thread struct that's > allocated on the heap, and I cons stuff onto it, do I have to do > anything special to prevent the GC from collecting the SCM contents > of the struct? Yes. As Rob already has explained, any Scheme object stored in a data structure allocated outside the stack must be explicitly protected. The way to do it in this case is to add a line in threads.c:thread_mark: static SCM thread_mark (SCM obj) { scm_thread *t = SCM_THREAD_DATA (obj); scm_gc_mark (t->result); scm_gc_mark (t->cancellation_handler_list); /* <--- */ return t->root->handle; /* mark root-state of this thread */ } Note, though, that this is the easy part. I do expect that there also could arise nasty complications having to do with the order in which things are done at cancellation. It's for example important that the scm_thread data structure isn't deallocated before the handlers are invoked. It's also important that the GC is still aware of the thread at that point in time. It's important that the thread *is* properly deallocated *after* the handlers have run---that kind of stuff. But maybe there's no problem at all. M _______________________________________________ Guile-devel mailing list Guile-devel@gnu.org http://lists.gnu.org/mailman/listinfo/guile-devel