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 BAA21867; Tue, 13 Apr 2004 01:31:03 +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 BAA21922 for ; Tue, 13 Apr 2004 01:31:02 +0200 (MET DST) Received: from herd.plethora.net (herd.plethora.net [205.166.146.1]) by concorde.inria.fr (8.12.10/8.12.10) with ESMTP id i3CNV0YM018515 for ; Tue, 13 Apr 2004 01:31:01 +0200 Received: from bhurt.plethora.net (bhurt.plethora.net [205.166.146.49]) by herd.plethora.net (8.11.6/8.10.1) with ESMTP id i3CNUnQ06239; Mon, 12 Apr 2004 18:30:53 -0500 (CDT) Date: Mon, 12 Apr 2004 19:37:09 -0500 (CDT) From: Brian Hurt X-X-Sender: bhurt@localhost.localdomain To: John Goerzen cc: caml-list@inria.fr Subject: Re: [Caml-list] Threading: Using and Building In-Reply-To: <20040412151948.GA11370@excelhustler.com> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Miltered: at concorde by Joe's j-chkmail ("http://j-chkmail.ensmp.fr")! X-Loop: caml-list@inria.fr X-Spam: no; 0.00; caml-list:01 threading:01 threads:01 implemented:01 threading:01 threads:01 introductory:99 behave:01 slows:01 mpi:01 forks:01 slower:01 slower:01 ocaml:01 ocaml:01 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk X-Status: X-Keywords: X-UID: 262 On Mon, 12 Apr 2004, John Goerzen wrote: > Hello, > > I am looking at using multi-threaded programs in OCaml, but have some > questions: > > *** Regarding the thread support itself > > Chapter 24 of the OCaml documentaion says that "The threads library is > implemented by time-sharing on a single processor. It will not take > advantage of multi-processor machines." That's bad. > > But then later on I notice that there are two threading options: system > threads and VM-level threads. The introductory paragraph does not seem > to apply to system threads which, in other languages at least, do not > behave that way. So I am rather puzzled about the actual level of > thread support is here. The threading is all user-space threading. It doesn't take advantage of multiple CPUs, doesn't use system threads, if one thread blocks they all block, etc. There are two problems with multithreading. First, it makes the GC more difficult and more costly. Currently, the GC runs in the same system thread as everything else, and thus it doesn't have synchronization issues. In a multi-threaded environment, you have synchronization issues which slows things down. Second, most people don't know how to write safe, correct, efficient multithreaded programs. It's harder than it looks. I think something like MPI between seperate processes would be a better way to take advantage of multi-processors. On Unix, you don't lose much doing multi-proccess (forks) instead of threads. Switching between processes in Unix isn't any slower than switching between threads within a process. But I've seen benchmarks which show that task switching between seperate processes was signifigantly slower than switching between threads within a process on NT4 (and that switching between threads on NT4 was about as expensive as switching between processes on Unix). They may have fixed this, or they may not have. -- "Usenet is like a herd of performing elephants with diarrhea -- massive, difficult to redirect, awe-inspiring, entertaining, and a source of mind-boggling amounts of excrement when you least expect it." - Gene Spafford Brian ------------------- 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