Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>On Windows there is underlying OS support for non-blocking I/O, and Microsoft's CLR takes advantage of that. Other CLR implementations (mono) probably do as well, but I don't know for sure. When performing async I/O on the Microsoft CLR there is not a 1-to-1 correlation between pending async I/O operations and threads (or at least managed threads) waiting for those I/O operations to complete.</p> <p>See <a href="http://msdn.microsoft.com/en-us/library/windows/desktop/aa365683(v=vs.85).aspx" rel="nofollow">http://msdn.microsoft.com/en-us/library/windows/desktop/aa365683(v=vs.85).aspx</a> for some details on the Win32-layer details. Also the information on I/O completion ports here: <a href="http://msdn.microsoft.com/en-us/library/aa365198(VS.85).aspx" rel="nofollow">http://msdn.microsoft.com/en-us/library/aa365198(VS.85).aspx</a></p> <p>My understanding is this:</p> <ol> <li>I begin an async I/O operation on some application thread.</li> <li>If it hasn't already, a queue will be created (well, really a kernel-level construct called an I/O completion port, which is associated with a queue in the kernel space of my application). In the .NET world a specially designated thread called an I/O completion port thread will start waiting for notifications of I/O completion on that queue. The important thing to note here is that I can make any number of async I/O requests without increasing the number of I/O completion ports.</li> <li>The OS will notify the application when I/O completes by enqueueing an I/O completion message on the queue. The I/O completion port thread will then handle that message by invoking the I/O completion callback in my .NET application. In the meantime, if other I/O completes, it's results will be enqueued behind the currently-processing results.</li> </ol> <p>Caveats to the above: </p> <ol> <li><p>I am sure I got part of this wrong, but I believe the overall gist of it is correct. Eric or someone can come in and correct me where I'm off.</p></li> <li><p>In .NET there are multiple I/O completion port threads. I have no idea how async I/O requests are allocated amongst the various I/O completion ports. This may be an operating system feature (wherein I/O may come back on any port that the application has open).</p></li> </ol> <p>For Java I am sure it depends on the JVM implementation and the particular OS. I don't know it nearly well enough to speculate beyond that.</p> <p>EDIT: Historical update, many more details <a href="http://msdn.microsoft.com/en-us/library/windows/desktop/aa365198(v=vs.85).aspx" rel="nofollow">here</a></p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload