[Haskell-cafe] Why do "unsafe" foreign calls block other threads?

John Meacham john at repetae.net
Tue Aug 3 18:23:29 EDT 2010


On Tue, Aug 03, 2010 at 02:54:40PM -0700, Gregory Crosswhite wrote:
> Could someone explain to me the logic behind having "unsafe" calls block
> other threads from executing?  It seems to me that if anything it would
> make more sense for "safe" calls to block other threads since the call
> can call back into the Haskell runtime, as opposed to "unsafe" calls
> which (by assertion) will never call back into Haskell and therefore
> should be safer to run in parallel with other threads.  What am I
> missing here?

It is more an accident of ghc's design than anything, the same mechanism
that allowed threads to call back into the runtime also allowed them to
be non blocking so the previously used 'safe' and 'unsafe' terms got
re-used. personally, I really don't like those terms, they are
non-descriptive in terms of what they actually mean and presuppose a RTS
similar to ghcs current design. 'reentrant' and 'blocking' which could
be specified independently would be better and would be more
future-proof against changes in the RTS or between compilers.

        John

-- 
John Meacham - ⑆repetae.net⑆john⑈ - http://notanumber.net/


More information about the Haskell-Cafe mailing list