[Haskell-cafe] concurrency vs. I/O in GHC

Brandon Moore brandon_m_moore at yahoo.com
Sat Oct 23 20:08:56 EDT 2010

On Oct 23, 2010, at 2:57 PM, Claude Heiland-Allen <claudiusmaximus at goto10.org> wrote:

On 23/10/10 17:42, Gregory Crosswhite wrote:
On 10/23/10 7:54 AM, John Lato wrote:
On Fri, Oct 22, 2010 at 6:16 PM, Bulat Ziganshin
<bulat.ziganshin at gmail.com <mailto:bulat.ziganshin at gmail.com>> wrote:

Hello John,

Monday, October 18, 2010, 8:15:42 PM, you wrote:

> If anyone is listening, I would very much like for there to be a
> mechanism by which external functions can be called "unsafe"-ly, but
> without blocking all other Haskell threads. I have code that
does this:

+RTS -N2

This doesn't work, which was why the OP asked in the first place. When
a thread calls an unsafe foreign function, it blocks everything until
that function returns.

Is that true? The last time we discussed this in Haskell Cafe the
conclusion I drew from the discussion was that unsafe foreign functions
block the current thread but not any other thread.

The conclusion I drew was that "unsafe" foreign functions block the current "capability" (OS thread) and any "threads" (Haskell forkIO etc) currently scheduled on that capability, but other capabilities and threads continue executing as normal.

I haven't tested it recently, but I think that is mostly correct except that an unsafe call will also prevent major collections, which will eventually tie up the rest of the capabilities as well.


More information about the Haskell-Cafe mailing list