Re: Async File IO is not async?
Peter Ritchie <[email protected]>
| Newsgroups | gmane.comp.windows.devel.dotnet.clr |
|---|---|
| Message-ID | <LISTSERV%[email protected]> |
On Fri, 18 Jan 2008 13:27:24 -0600, Alex Ivanoff >My definition of "true" async IO is that BeginXXX return immediately. Overlapped IO to the file system doesn't work that way, you still have to check to see if the operation was performed asynchronously or not (which BeginXXXCore does). Overlapped IO uses a limited pool of worker threads, if all threads in that pool are in use, overlapped IO will be synchronous. BeginXXX is written to use overlapped IO. The only difference is that it doesn't use FILE_FLAG_NO_BUFFERING, but that's not documented as guaranteeing async io either--at least outside of a KB article. KB articles may be written by non-MSFT employees and may not be reviewed before posting. FILE_FLAG_NO_BUFFERING does imply some restrictions on the way the reads and writes occur: "disk reads and writes must be done on sector boundaries, and buffer addresses must be aligned on disk sector boundaries in memory." [1] You could try manually creating the file handle (with FILE_FLAG_NO_BUFFERING) and using the FileStream(SafeFileHandle, FileAccess) constructor to see if you get a more asynchronous call... >Bottom line, I think the implementation of FileStream when the wrapped >handle is physical file is broken as far as async IO goes. I disagree--it's as async as overlapped IO is. And BeginWrite is documented with "FileStream provides two different modes of operation: synchronous I/O and asynchronous I/O. While either can be used, the underlying operating system resources might allow access in only one of these modes." It also goes on to suggest using FileStream(String, FileMode, FileAccess, FileShare, Int32, Boolean) [2] which, on the useAsync parameter, further points out that "However, note that the underlying operating system might not support asynchronous I/O, so when specifying true, the handle might be opened synchronously depending on the platform.". ...but, you can always log an issue on http://connect.microsoft.com/visualstudio [1] http://support.microsoft.com/kb/99794 [2] http://msdn2.microsoft.com/en-us/library/7db28s3c.aspx =================================== This list is hosted by DevelopMentor® http://www.develop.com View archives and manage your subscription(s) at http://discuss.develop.com