Version française
Home     About     Download     Resources     Contact us    
Browse thread
Re: [Caml-list] native threads not parallel?
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: james woodyatt <jhw@w...>
Subject: Re: [Caml-list] native threads not parallel?
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:
> <http://groups.google.com/ 
> groups?selm=fa.dlqoshv.1a66ho7%40ifi.uio.no&output=gplain>

On Mon, 25 Nov 2002 10:04:54 GMT, Xavier Leroy <xavier.leroy@inria.fr>  
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 <jhw@wetware.com>

-------------------
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