From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by yquem.inria.fr (Postfix) with ESMTP id 8B4E3BCA2 for ; Wed, 17 Aug 2005 07:39:09 +0200 (CEST) Received: from pauillac.inria.fr (pauillac.inria.fr [128.93.11.35]) by nez-perce.inria.fr (8.13.0/8.13.0) with ESMTP id j7H5d8WO014848 for ; Wed, 17 Aug 2005 07:39:08 +0200 Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id HAA17309 for ; Wed, 17 Aug 2005 07:39:08 +0200 (MET DST) Received: from ciao.gmane.org (main.gmane.org [80.91.229.2]) by nez-perce.inria.fr (8.13.0/8.13.0) with ESMTP id j7H5d72f014837 (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NO) for ; Wed, 17 Aug 2005 07:39:08 +0200 Received: from list by ciao.gmane.org with local (Exim 4.43) id 1E5GcN-0006Mn-4O for caml-list@inria.fr; Wed, 17 Aug 2005 07:37:39 +0200 Received: from 0x50a5bb8d.odnxx9.adsl-dhcp.tele.dk ([80.165.187.141]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Wed, 17 Aug 2005 07:37:39 +0200 Received: from spam by 0x50a5bb8d.odnxx9.adsl-dhcp.tele.dk with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Wed, 17 Aug 2005 07:37:39 +0200 X-Injected-Via-Gmane: http://gmane.org/ To: caml-list@inria.fr From: Bardur Arantsson Subject: Re: Stopping a value from getting GC'd Date: Wed, 17 Aug 2005 07:36:50 +0200 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Complaints-To: usenet@sea.gmane.org X-Gmane-NNTP-Posting-Host: 0x50a5bb8d.odnxx9.adsl-dhcp.tele.dk User-Agent: Mozilla Thunderbird 1.0.6 (X11/20050803) X-Accept-Language: en-us, en In-Reply-To: Sender: news X-Miltered: at nez-perce with ID 4302CD7C.002 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Miltered: at nez-perce with ID 4302CD7B.001 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; gc'd:01 struct:01 struct:01 char:01 stack:01 char:01 pointer:01 typedef:01 val:01 camlparam:01 alloc:01 camlreturn:01 val:01 rtfm:01 sdu:01 X-Spam-Checker-Version: SpamAssassin 3.0.3 (2005-04-27) on yquem.inria.fr X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=disabled version=3.0.3 Jonathan Roewen wrote: > Hi, > > I have the following in my C code: > > struct caml_thread_struct { > char * bottom_of_stack; > unsigned long last_retaddr; > value * gc_regs; > char * exception_pointer; > struct caml__roots_block * local_roots; > int is_running; > value closure; > }; > > typedef struct caml_thread_struct * caml_thread_t; > > static value Val_thread(caml_thread_t thread) { > CAMLparam0(); > CAMLlocal1(rv); > rv = caml_alloc(1, Abstract_tag); > Field(rv,0) = (value) thread; > CAMLreturn(rv); > } > > #define Thread_val(rv) ((caml_thread_t)Field((rv),0)) > > Now my question is, since my Thread.t is abstract, once I pass my > value to my Thread.create, there'll soon be nothing referencing the > closure for the thread that's visible by the GC. > > If I'm correct, the GC would then be allowed to reclaim this closure. > So how do I stop the GC from doing that? > register_global_root (or as some others would say: RTFM). -- Bardur Arantsson - Oh, did I say corpse hatch? I meant... innocence tube. Montgomery Burns, 'The Simpsons'