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

Gregory Crosswhite gcross at phys.washington.edu
Tue Aug 3 18:33:40 EDT 2010

 On 08/03/10 15:23, John Meacham wrote:
> 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
Okay, that makes a lot more sense.  So really when marking a call "safe"
or "unsafe" I shouldn't be thinking in terms of whether I want to avoid
the increased overhead of allowing it to call back into Haskell, but
rather I should be considering whether I want to call to block other
threads or not.  However, it would seem that within this scheme there is
no way for me to specify that a foreign call should be both "blocking"
and also allowed to call Haskell functions, which to me would be the
"safe"est possible alternative.


More information about the Haskell-Cafe mailing list