From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from majordomo@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id FAA23700; Fri, 21 Feb 2003 05:24:16 +0100 (MET) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f 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 FAA23681 for ; Fri, 21 Feb 2003 05:24:15 +0100 (MET) Received: from xanadu.ece.ucsb.edu (xanadu.ece.ucsb.edu [128.111.56.51]) by nez-perce.inria.fr (8.11.1/8.11.1) with ESMTP id h1L4ODH05184 for ; Fri, 21 Feb 2003 05:24:14 +0100 (MET) Received: from cbshost-12-107-11-69.sbcox.net (cbshost-12-107-11-69.sbcox.net [12.107.11.69]) by xanadu.ece.ucsb.edu (8.12.2/8.12.2) with ESMTP id h1L4OCPr019936 for ; Thu, 20 Feb 2003 20:24:12 -0800 (PST) Subject: Re: [Caml-list] native threads not parallel? From: shivkumar chandrasekaran To: caml-list@inria.fr In-Reply-To: <20030221091524C.garrigue@kurims.kyoto-u.ac.jp> References: <847A10BA-4528-11D7-8C93-000393942C76@ece.ucsb.edu> <20030221091524C.garrigue@kurims.kyoto-u.ac.jp> Content-Type: text/plain Content-Transfer-Encoding: 7bit X-Mailer: Ximian Evolution 1.0.8 (1.0.8-10) Date: 20 Feb 2003 20:24:12 -0800 Message-Id: <1045801453.1601.8.camel@cbshost-12-107-11-69.sbcox.net> Mime-Version: 1.0 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk On Thu, 2003-02-20 at 16:15, Jacques Garrigue wrote: > From: Shivkumar Chandrasekaran > > > not. But I seem to have the same problem as discussed by Markus Mottl > > (see attachment below) on Mac OS X 10.2.4 on a dual processor G4 > > machine. An earlier message in that thread mentioned that there was no > > such problem on dual-processor Linux machines. > > Let's answer again, since this is a frequent question: ocaml threads > do not not support parrallelism. Only one ocaml thread will run at a > time, independently of the number of processors, and this on any > architecture/OS. > Sorry, but let me ask again. I *know* that ocaml threads cannot use multiple processors. That was not the subject of the thread I cited. I should have been clearer. If I am recalling correctly, Xavier has mentioned before that in *native-code* (see subject) ocaml will allow C code to run in parallel. Markus' email was precisely on that point as was mine. I have C code that I would like to execute on a processor different from the ocaml thread one. Apparently, as I gather from the cited email of Markus Mottl, this did occur (at least on some dual processor Linux machines) when the corresponding C code was bracketed with "enter/leaving_blocking section ()" calls, and, *I assume*, calling the C-code from a separate ocaml thread using Thread.create. I understand the dangers about calling back into caml from the bracketed C-code. The preceding thread I cited discussed this as well, as you mentioned. Thanks, --shiv-- > > > From :Markus Mottl < mottl@miss.wu-wien.ac.at > > > > The only thing I can imagine is that OCaml somehow changes > > > scheduling so that the threads cannot run in parallel anymore, even if > > > "enter_blocking_section" is used. Is this possible? Or am I just making > > > some stupid mistake? > > enter_blocking_section only happens in C code, and is followed by a > leave_blocking_section before returning to caml code. Since the > leave_blocking_section reacquires the lock, no more than one ocaml > thread can run simultaneously. > Easy way to crash the runtime: call a caml callback immediately after > an enter_blocking_section. The two caml threads will start to > allocate simultaneously on the same heap, without any locking... > > Jacques Garrigue > ------------------- > To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr > Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/ > Beginner's list: http://groups.yahoo.com/group/ocaml_beginners -- Professor Shivkumar Chandrasekaran || phn: 805.893.7542 Electrical & Computer Engineering Department || fax: 805.893.3262 University of California || Office: 3109, Eng. I Santa Barbara, CA 93106-9560 || email: shiv@ece.ucsb.edu ------------------- To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/ Beginner's list: http://groups.yahoo.com/group/ocaml_beginners