Questions on the RTS C API regarding threads and tasks

Gregory Collins greg at
Mon Nov 9 20:33:25 UTC 2015

On Mon, Nov 9, 2015 at 6:02 AM, Nicola Gigante <nicola.gigante at>

> Nothing actually, I was confused about what “unsafe” call means.

In fact, as you've probably realized, the reason these calls are labeled
unsafe is precisely because they don't yield the capability. An unsafe FFI
call that blocks will block the Haskell capability -- this not only starves
that CPU for actual work, it will eventually block the whole program once
the RTS tries to do a round of stop-the-world GC.

As Edward pointed out, you're better off just relying on the concurrency
primitives Haskell already gives you unless you find they're too slow.
Another thing you can try is the unagi-chan library on Hackage (, which offers versions of
blocking and non-blocking producer-consumer queues that claim to be much
faster than the ones that come with the standard library.

Gregory Collins <greg at>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the ghc-devs mailing list