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 CAA21488; Fri, 21 Feb 2003 02:57:15 +0100 (MET) 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 CAA21495 for ; Fri, 21 Feb 2003 02:57:15 +0100 (MET) Received: from wetware.wetware.com (wetware.wetware.com [199.108.16.1]) by concorde.inria.fr (8.11.1/8.11.1) with ESMTP id h1L1vDT10411 for ; Fri, 21 Feb 2003 02:57:14 +0100 (MET) Received: from wetware.com(ra06.wetware.com[199.108.16.86]) (3344 bytes) by wetware.wetware.com via sendmail with P:esmtp/R:bind_hosts/T:inet_zone_bind_smtp (sender: ) id for ; Thu, 20 Feb 2003 17:57:08 -0800 (PST) (Smail-3.2.0.114 2001-Aug-6 #1 built 2002-Sep-2) Date: Thu, 20 Feb 2003 17:56:03 -0800 Subject: Re: [Caml-list] native threads not parallel? Content-Type: text/plain; delsp=yes; charset=US-ASCII; format=flowed Mime-Version: 1.0 (Apple Message framework v551) From: james woodyatt To: The Trade Content-Transfer-Encoding: 7bit In-Reply-To: Message-Id: X-Mailer: Apple Mail (2.551) Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk On Thursday, Feb 20, 2003, at 16:32 US/Pacific, Chris Uzdavinis wrote: > > Here's the best/most detailed answer to your question that I've seen: > groups?selm=fa.dlqoshv.1a66ho7%40ifi.uio.no&output=gplain> On Mon, 25 Nov 2002 10:04:54 GMT, Xavier Leroy wrote: > It seems that the annual discussion on threads started again. Allow > me to deliver again my standard lecture on this topic. > > Threads have at least three different purposes: > > 1- Parallelism on shared-memory multiprocessors. > 2- Overlapping I/O and computation (while a thread is blocked on a > network > read, other threads may proceed). > 3- Supporting the "coroutine" programming style > (e.g. if a program has a GUI but performs long computations, > using threads is a nicer way to structure the program than > trying to wrap the long computation around the GUI event loop). > > The goals of OCaml threads are (2) and (3) but not (1) (for reasons > that I'll get into later), with historical emphasis on (2) due to the > MMM (Web browser) and V6 (HTTP proxy) applications. > [...] > In summary: there is no SMP support in OCaml, and it is very very > unlikely that there will ever be. If you're into parallelism, better > investigate message-passing interfaces. And I'm not sure that (2) is better done with threads and shared memory than with message passing and processes-- especially if you've a got a good solution for just doing (3) with a userland continuation scheduler. (Now that I've learned a few more things about FP, I'm working on another pass at this that will hopefully not suck wind like my previous offering did.) If you have a good userland scheduler, i.e. something that just throws around continuations in a reasonable way, and you're willing to go to message passing to get overlapping I/O and computation, then you can get parallelism on MP machines by just passing messages around between processes in the kernel. However, I can think of a fourth purpose for SMP support: to permit OCaml functions to be usable as plugins to multi-threaded application programming frameworks in other languages, e.g. C, C++, Obj-C, Java, C#, etc. without having to make the OCaml runtime environment a critical section for every thread in the application. I'm hard pressed to think of a good example where this might be worth doing, though... Personally, I'm happy to continue expecting to get parallelism from message passing between distributed processes. Fifteen years of coding under VxWorks (and Solaris with POSIX threads) has cured me of the desire for more preemptive multithreading with shared memory. -- j h woodyatt ------------------- 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