[Haskell-cafe] Parallel cooperative multithreading?

Mario Blažević blamario at acanac.net
Thu May 24 05:41:52 CEST 2012


On 12-05-22 09:55 AM, Benjamin Ylvisaker wrote:
> Has anyone ever worked on implementing something like this in Haskell?
>
> http://www.cs.hmc.edu/~stone/papers/ocm-unpublished.pdf
>
> The outline of the idea:
>
> - Concurrent programming is really hard with the popular frameworks
> today.
> - For most purposes parallel programming is hard, in some part because
> it requires concurrent programming.  Of course there are attempts to do
> non-concurrent parallel programming, but I hope it's not too
> controversial to say that such frameworks are still on the fringe.
> - Cooperative concurrency is way easier than preemptive concurrency
> because between invocations of pause/yield/wait, sequential reasoning
> works.
> - Historically, cooperative concurrency only worked on a single
> processors, because running threads in parallel would break the
> atomicity of sequential blocks (between invocations of p/y/w).
> - Researchers have been poring tons of effort into efficiently running
> blocks of code atomically.
> - Hey, we can do parallel cooperative multithreading!
>
> The paper discusses implementations in Lua, C++ and C, but I think
> Haskell could be an awesome substrate for such a framework.  Has anyone
> thought about this?

     I have, which is why the monad-coroutine library comes with support 
for running multiple coroutines in parallel, meaning that their steps 
are run in parallel rather than interleaved. Unfortunately, I never 
managed to extract any actual speedup out of this feature in my tests.




More information about the Haskell-Cafe mailing list