Multiple C threads -> one unthreaded GHC RTS

Brandon Allbery allbery.b at
Thu Sep 28 21:08:16 UTC 2017

On Thu, Sep 28, 2017 at 4:57 PM, Albert Y. C. Lai <trebla at> wrote:

> Suppose I have a C program with multiple C threads calling Haskell
> functions, maybe the same Haskell function too, and the GHC RTS used is the
> unthreaded one. What will go wrong?
> I ask because Cabal/cabal-install has recently added building of
> export-to-C shared libraries, i.e., the "foreign-library" section. It sees
> to all the technical details, very nice, I'm very happy about this
> addition, but it chooses the unthreaded GHC RTS.

I don't expect the unthreaded RTS to be reentrant, so would expect you to
need locking around calls into it to avoid the dreaded 'scheduler entered
unsafely!' RTS error. And thread-local storage might be an issue.

brandon s allbery kf8nh                               sine nomine associates
allbery.b at                                  ballbery at
unix, openafs, kerberos, infrastructure, xmonad
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the Glasgow-haskell-users mailing list