[Haskell-cafe] Unbound threads and FFI
simonmar at microsoft.com
Wed Dec 14 10:21:49 EST 2005
On 14 December 2005 14:37, Joel Reymont wrote:
> How do unbound threads play with FFI? According to Simon PJ, each
> foreign call will get its own OS thread if its blocked.
> How does GHC determine if the call is blocked? Does each call get its
> own OS thread from the start? Sometime later?
When a thread exits Haskell to make an FFI call, another OS thread takes
over running the other Haskell threads. If we don't have another OS
thread available, we start one.
> Does this depend on the safe/unsafe specs of the foreign call?
this only happens for safe calls, not unsafe.
> Does the above change if a threaded/non-threaded runtime is in use?
this only happens in the -threaded RTS, in the non-threaded RTS a FFI
call will block all the other Haskell threads.
More information about the Haskell-Cafe