[Haskell-cafe] System calls and Haskell threads

Johan Tibell johan.tibell at gmail.com
Thu Nov 3 17:26:01 CET 2011

On Thu, Nov 3, 2011 at 8:35 AM, Andreas Voellmy
<andreas.voellmy at gmail.com>wrote:

> I just read Kazu Yamamoto's article on a high performance web server in
> the latest Monad.Reader, and I came across a statement that doesn't sound
> correct to me. He says:
> "When a user thread issues a system call, a context switch occurs. This
> means that all Haskell user threads stop, and instead the kernel is given
> the CPU time. "
> Is this right? I thought that when a system call is made by a Haskell
> thread being run by a particular worker thread on a CPU, other runnable
> Haskell threads in the run queues of the HECs for other CPUs can continue
> running concurrently (provided we've run our Haskell program with multiple
> CPUs using the -Nx RTS argument). That's what I understood from the
> discussion of foreign calls in "Runtime Support for Multicore Haskell".

That's correct. Blocking syscalls will not prevent other Haskell threads
from running. IIRC it will block the OS thread used to run the Haskell
thread making the blocking syscall, but the RTS always has one free OS
thread (i.e. it will allocated more if needed) that it can use to continue
running other Haskell threads with. Your best reference is probably
"Extending the Haskell Foreign Function Interface with Concurrency".

-- Johan
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/haskell-cafe/attachments/20111103/2e7edb2f/attachment.htm>

More information about the Haskell-Cafe mailing list