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 nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by yquem.inria.fr (Postfix) with ESMTP id 7F5ECBB81 for ; Sat, 15 Oct 2005 10:46:11 +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 j9F8kACP018204 for ; Sat, 15 Oct 2005 10:46:10 +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 KAA15980 for ; Sat, 15 Oct 2005 10:46:10 +0200 (MET DST) Received: from kurims.kurims.kyoto-u.ac.jp (kurims.kurims.kyoto-u.ac.jp [130.54.16.1]) by nez-perce.inria.fr (8.13.0/8.13.0) with ESMTP id j9F8k8QZ018199 for ; Sat, 15 Oct 2005 10:46:09 +0200 Received: from localhost (suiren [130.54.16.25]) by kurims.kurims.kyoto-u.ac.jp (8.13.1/8.13.1) with ESMTP id j9F8k4ok009331; Sat, 15 Oct 2005 17:46:05 +0900 (JST) Date: Sat, 15 Oct 2005 17:46:01 +0900 (JST) Message-Id: <20051015.174601.119244280.garrigue@math.nagoya-u.ac.jp> To: itz@buug.org Cc: caml-list@inria.fr Subject: Re: [Caml-list] vm threads From: Jacques Garrigue In-Reply-To: <87zmpb9viq.fsf@buug.org> References: <8764rzbcw6.fsf@buug.org> <20051015.142304.106269859.garrigue@math.nagoya-u.ac.jp> <87zmpb9viq.fsf@buug.org> X-Mailer: Mew version 4.2 on Emacs 21.3 / Mule 5.0 (SAKAKI) Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Miltered: at nez-perce with ID 4350C1D2.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Miltered: at nez-perce with ID 4350C1D0.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; caml-list:01 threads:01 itz:01 threads:01 ocaml:01 ocaml:01 atm:98 ...:98 unix:01 zimmerman:01 jacques:01 jacques:01 primitives:02 thread:02 thread:02 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 From: Ian Zimmerman > The reason I asked was: when writing a library that uses C extension > code and a global data structure in the C code, can I just use system > thread primitives for synchronization (that would be pthreads since > I am only thinking about Unix type systems at least ATM) and not worry > about VM threads? > > From your post the answer seems to be yes. That's even stronger than that: if you do not plan to run some pure C threads concurently with ocaml, you usually don't need any synchronization, either for system or VM threads. With VM threads, you may only change thread when executing ocaml code, so all your C code is single-threaded. With system threads, you have to release the ocaml lock by calling enter_blocking_section before any other ocaml thread may run. If you don't want to be interrupted, just don't release it. So you don't need to bother with synchronization as long as you don't introduce concurrency intentionally on the C side. (But this might be what you intend to do...) Jacques Garrigue