[MLton] More on parallelism

skaller skaller at users.sourceforge.net
Tue Dec 5 09:22:05 PST 2006


On Tue, 2006-12-05 at 11:42 -0500, Matthew Fluet wrote:

> > Please don't do this.
> > I think people would want two different Thread interfaces; one for "OS" 
> > threads and one for the kind that exist now.
> 
> Can you justify this choice?  I don't have a lot of intuition here.  

OS level threads are required for parallelism, that is, using
multiple CPUs (at least on major OS). Cooperatively 
multiplexed threads -- fibres -- have different properties. 
Interaction is more lightweight and
doesn't require protection of shared memory.

In Felix, the interfaces are similar: threads and channels
in both cases. However pthreads requires locks to protect
shared memory access wheres fthread (fibres) do not.

An interesting property of fibres in Felix is that provided
the fibres are anonymous, the system cannot deadlock. 
Pthreads don't have this property. Fibres also have no
notion of fairness, whereas pthreads potentially do.

In many applications you need to know the difference
between these kinds of threads, even if you have a
common abstraction that allows some code to work with
either kind, in general this won't be the case.

-- 
John Skaller <skaller at users dot sf dot net>
Felix, successor to C++: http://felix.sf.net



More information about the MLton mailing list