From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from mail4-relais-sop.national.inria.fr (mail4-relais-sop.national.inria.fr [192.134.164.105]) by yquem.inria.fr (Postfix) with ESMTP id B32D9BBAF for ; Thu, 25 Feb 2010 08:26:08 +0100 (CET) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AgwCABS1hUvZSMDqjWdsb2JhbACbFRUBAQEBCQkKCREFH7wThHMEhhc X-IronPort-AV: E=Sophos;i="4.49,537,1262559600"; d="scan'208";a="57767955" Received: from fmmailgate03.web.de ([217.72.192.234]) by mail4-smtp-sop.national.inria.fr with ESMTP; 25 Feb 2010 08:26:08 +0100 Received: from smtp06.web.de (fmsmtp06.dlan.cinetic.de [172.20.5.172]) by fmmailgate03.web.de (Postfix) with ESMTP id D3B6B13FFB0A0; Thu, 25 Feb 2010 08:25:31 +0100 (CET) Received: from [85.216.85.71] (helo=frosties.localdomain) by smtp06.web.de with asmtp (TLSv1:AES256-SHA:256) (WEB.DE 4.110 #314) id 1NkY6F-0002sz-00; Thu, 25 Feb 2010 08:25:31 +0100 Received: from mrvn by frosties.localdomain with local (Exim 4.71) (envelope-from ) id 1NkY6E-00036R-Td; Thu, 25 Feb 2010 08:25:31 +0100 From: Goswin von Brederlow To: Philippe Wang Cc: Goswin von Brederlow , caml-list Subject: Re: [Caml-list] Question about ocaml threads and TLS (on linux) References: <87ocje2vtv.fsf@frosties.localdomain> <4d1b2df21002241322l63b82636hf7465ec05de9d8ed@mail.gmail.com> Date: Thu, 25 Feb 2010 08:25:30 +0100 In-Reply-To: <4d1b2df21002241322l63b82636hf7465ec05de9d8ed@mail.gmail.com> (Philippe Wang's message of "Wed, 24 Feb 2010 22:22:06 +0100") Message-ID: <87635l4w0l.fsf@frosties.localdomain> User-Agent: Gnus/5.110009 (No Gnus v0.9) XEmacs/21.4.22 (linux, no MULE) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Sender: goswin-v-b@web.de X-Sender: goswin-v-b@web.de X-Provags-ID: V01U2FsdGVkX1/BMRoPmtTc7FAHuTkNSZE0J3fBs6JiHLinc6AP Yn3m3IEA5yfVRfvZ1PCsUTQu+HHLRuq8lMt5BUh88eH89UzVwL UbEjS0OUY= X-Spam: no; 0.00; ocaml:01 ocaml:01 compiler:01 ocamlopt:01 stub:01 stub:01 bytecode:01 ocaml's:01 runtime:01 compiler:01 pointer:01 buf:01 cheers:01 mfg:98 threads:01 Philippe Wang writes: > Hi, > > I'm not sure I understand (though I've read the whole text), but maybe > this will answer your question: > On Linux, OCaml threads (with the native compiler "ocamlopt") are > implemented with POSIX threads (in C), so when your OCaml thread runs > the C stub, it's the same as if you were running the C stub in some C > thread. How about bytecode? > When you are in a section declared as a blocking section, a collection > can be triggered concurrently in another thread and so the heap must > not be accessed neither for reading or writing, that's all. > > Using __thread recent feature should also work if you manage to > compile everything correctly. Notably, we use it in some places in > ocaml4multicore (a patch to ocaml's runtime library to allow parallel > threads). However, I don't know how __thread is handled by the > compiler... I mean : it there a pointer for buf in every thread or > only in those that use it? Only in those that use it. But that will be multiple threads. In those that don't use it 4/8 bytes will be wasted. > I hope my answer isn't useless! > > Cheers, MfG Goswin