Dmitry Kurochkin wrote:
> What confused me was this paragraph from forkOS doc:
>
> ...
> Just to clarify, forkOS is only necessary if you need to associate a
> Haskell thread with a particular OS thread. It is not necessary if you
> only need to make non-blocking foreign calls (see
> Control.Concurrent#osthreads).
> ...
>
> "non-blocking foreign calls" - so I thought that for blocking foreign
> calls forkIO is not enough.
That paragraph was supposed to clarify the situation, but I worded it quite
badly, sorry about that. I've rewritten the docs for forkOS completely now:
----
Like 'forkIO', this sparks off a new thread to run the 'IO'
computation passed as the first argument, and returns the 'ThreadId'
of the newly created thread.
However, 'forkOS' creates a /bound/ thread, which is necessary if you
need to call foreign (non-Haskell) libraries that make use of
thread-local state, such as OpenGL (see "Control.Concurrent#boundthreads").
Using 'forkOS' instead of 'forkIO' makes no difference at all to the
scheduling behaviour of the Haskell runtime system. It is a common
misconception that you need to use 'forkOS' instead of 'forkIO' to
avoid blocking all the Haskell threads when making a foreign call;
this isn't the case. To allow foreign calls to be made without
blocking all the Haskell threads (with GHC), it is only necessary to
use the @-threaded@ option when linking your program, and to make sure
the foreign import is not marked @[EMAIL PROTECTED]
---
Cheers,
Simon
_______________________________________________
darcs-users mailing list
[email protected]
http://lists.osuosl.org/mailman/listinfo/darcs-users