[MLton-user] where to next?

Stephen Weeks sweeks@sweeks.com
Tue, 4 Jul 2006 17:34:53 -0700


> >  * Support for multi-core.
...
> Haskell of course does SMP by noting "Since our language is pure,
> there is no danger in both CPUs calculating the same computation and
> giving the result twice and therefore we can avoid locking in many
> cases" (greatly simplified)
...
> How to attack multi processor support in MLton is not clear to me,
> since SML is imperative at its core.

I have a half-baked idea that one could present a model of
non-preemptive threads to the programmer while allowing threads to run
simultaneously (in the true multi-core sense) underneath.  The idea is
to automatically STM all ref cells and automatically make into STM
atomic regions the code between explicit yields or blocking operations
(like sending on a CML channel).  Then, threads run simultaneously and
use STM tricks to back out should one thread want to step on another
thread's ref cells.

If it could be implemented efficiently, it seems like it would be a
nice model.  Non-preemptive threads are easy to program because one
sees all the possible (conceptual) context-switch points.  Most code
automatically becomes thread safe without rewriting and one gets to
reason about code without worrying about interleaving with other
threads.