[Haskell-cafe] Questions about threads

Donn Cave donn at drizzle.com
Mon Jul 30 12:27:37 EDT 2007


On Mon, 30 Jul 2007, Duncan Coutts wrote:
...
> You generally do not want forkOS. It's really only for wierd foreign
> libs that require that they be called from the same OS thread every time
> eg because they keep thread local state (like OpenGL).

Can Haskell application code run in a thread created by the foreign
library?  I'm assuming some requirement for C level API to bootstrap
the new thread in the runtime.

...
> In both ghc only uses on OS thread for IO. In the threaded rts it's an
> *additional* OS thread but it's still only one.
> 
> In the single threaded rts, it's the rts that does the select/poll. In
> the threaded rts it's a Haskell IO manager thread that uses select/poll
> on behalf of other Haskell threads that need to block until the
> completion of I/O.

Can my own application's foreign I/O plug into that IO manager?

Does select work for all I/O?  For example, take DNS -
Network.BSD.getHostByName could involve some network I/O and a lengthy
delay, but as far as I know there isn't any select-friendly interface
even at the lower levels.  Or System.Posix.getProcessStatus, which
doesn't generate any I/O in the sense of a selectable device.

	Donn Cave, donn at drizzle.com



More information about the Haskell-Cafe mailing list