<div class="gmail_quote">On Thu, Nov 3, 2011 at 8:35 AM, Andreas Voellmy <span dir="ltr">&lt;<a href="mailto:andreas.voellmy@gmail.com">andreas.voellmy@gmail.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">

<div>I just read Kazu Yamamoto&#39;s article on a high performance web server in the latest Monad.Reader, and I came across a statement that doesn&#39;t sound correct to me. He says: </div><div><br></div><div>&quot;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. &quot;</div>


<div><br></div><div>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&#39;ve run our Haskell program with multiple CPUs using the -Nx RTS argument). That&#39;s what I understood from the discussion of foreign calls in &quot;Runtime Support for Multicore Haskell&quot;. <br>

</div></blockquote><div><br>That&#39;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 &quot;Extending the Haskell Foreign Function Interface with Concurrency&quot;.<br>

<br>-- Johan<br><br></div></div>