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 JAA00115; Tue, 20 Jul 2004 09:27:08 +0200 (MET DST) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id JAA32659 for ; Tue, 20 Jul 2004 09:27:07 +0200 (MET DST) Received: from kurims.kurims.kyoto-u.ac.jp (kurims.kurims.kyoto-u.ac.jp [130.54.16.1]) by concorde.inria.fr (8.12.10/8.12.10) with ESMTP id i6K7R4SH032660 for ; Tue, 20 Jul 2004 09:27:05 +0200 Received: from localhost (suiren.kurims.kyoto-u.ac.jp [130.54.16.25]) by kurims.kurims.kyoto-u.ac.jp (8.9.3p2-20030924/3.7W) with ESMTP id QAA04541; Tue, 20 Jul 2004 16:26:53 +0900 (JST) Date: Tue, 20 Jul 2004 16:26:53 +0900 (JST) Message-Id: <20040720.162653.05992362.garrigue@kurims.kyoto-u.ac.jp> To: coreyoconnor@gmail.com Cc: caml-list@inria.fr Subject: Re: [Caml-list] Threads question... From: Jacques GARRIGUE In-Reply-To: References: X-Mailer: Mew version 4.0.64 on Emacs 21.2 / Mule 5.0 (SAKAKI) Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Miltered: at concorde with ID 40FCC948.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Loop: caml-list@inria.fr X-Spam: no; 0.00; caml-list:01 threads:01 jacques:01 corey:99 threads:01 implemented:01 implemented:01 threading:01 posix:01 posix:01 jacques:01 caml:01 caml:01 blocking:01 blocking:01 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk From: "Corey O'Connor" > "The threads library is implemented by time-sharing on a single > processor. It will not take advantage of multi-processor machines. > Using this library will therefore never make programs run faster. > However, many programs are easier to write when structured as several > communicating processes." > > However, the documentation states that the native threads library is > implemented using the system's native threading. (POSIX threads, in my > case) > > Is the quote above still consistent with the native threads implementation? Basically, yes. With posix threads (or windows threads), every caml thread is mapped to a posix thread, but there is a global mutex which any caml thread must obtain before running. This makes sure for instance that memory allocation and GC work properly. So no more than one caml thread may run simultaneously, and you don't gain from multiple CPUs. However, contrary to vmthreads, this restriction only applies while executing caml code. If you call some C function, you may choose to first release the global lock (caml_enter_blocking_section), letting other caml threads work while you are on the C side. Don't forget to call lock again (caml_leave_blocking_section) when returning, or you will crash very soon. 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