[Haskell-cafe]Re: Hugsvs GHC (again)was: Re: Somerandomnewbiequestions

Simon Marlow simonmar at microsoft.com
Thu Jan 20 05:48:19 EST 2005

On 20 January 2005 10:01, Keean Schupke wrote:

> Simon Marlow wrote:
>> We're getting a bit confused here.  Keean: the original question was
>> about whether a disk read will stop all other *Haskell* threads. 
>> Not OS threads.  The two are quite different beasts in GHC.
>> Cheers,
>> 	Simon
> But if GHC is running with the -threaded flag, then other
> Haskell-threads can keep running using the second OS-thread, even
> though one Haskell-thread (and its associated OS thread) is blocking
> - right? 

If the call to read() was "safe" (i.e. the FFI "safe" attribute), then
yes.  But GHC currently does and "unsafe" call to read(), even with
-threaded, which doesn't give other threads a chance to run.

Perhaps it should be a safe call.  That's going to hurt performance
unless you really need to parallelise disk I/O, though.  Maybe it
wouldn't hurt too much, someone should measure it.

> In other words even with disk IO (as I said the kernel would not
> busy-wait - so there are
> only two options, this OS-thread is put to sleep, or the data is
> already in a buffer and is
> returned immediately), all the other Haskell-threads should not block
> (provided it is
> running with -threaded)
> Have I got that right?

Yes, except that you forgot that not all foreign calls can run
concurrently with Haskell code.  Only the "safe" ones can.


More information about the Haskell-Cafe mailing list