[Haskell-cafe] Questions about threads

John Goerzen jgoerzen at complete.org
Sun Jul 29 18:35:26 EDT 2007


Hi everyone, 

I have been confused by some things about threads for a long time.  I'm
hoping someone out there can help clear this up.  I'll clean up and
document on the wiki if we get conclusive answers.

So it seems there are four scenarios for firing off threads:

A) Threaded RTS, forkIO
B) Threaded RTS, forkOS
C) Non-threaded RTS, forkIO
D) Non-threaded RTS, forkOS

So the questions, for each of the four models, are:

1) What is the impact of firing off a thread to execute a pure (non-IO)
computation under each model?  Will multiple pure computations be
allowed to run in parallel, or will only one run at a time?  (While the
computation may be outside the IO monad, of course at the end it will
have to use IO to communicate the result back.)

2) What is the impact of IO under each model?  Will GHC internally use
select/poll/whatever?  Or will each thread get a dedicated OS thread
that uses synchronous I/O?

3) When signals are received, which thread receives them?

4) When forkProcess is executed, which thread(s) are duplicated to the
forked process?

5) What does an FFI import "safe" mean under each model?

6) What does an FFI import "unsafe" mean under each model?

7) What is the expected future level of support for each model?  This is
of significant concern to me, as it appears that the threaded RTS is
only supported on an extremely limited set of architectures (most
programs won't even link on Debian's autobuilders if I use -threaded).
Also I have heard comments that the non-threaded RTS may be dropped in
the future.

8) What is the expected level of support for STM in combination with
each threaded model?

9) How does par mix with each threaded model?  Is it equivolent to
forkOS or forkIO?

Thanks,

-- John



More information about the Haskell-Cafe mailing list