Windows’ kernel I/O manager will serialize I/O requests automatically if you didn’t have the flag FILE_FLAG_OVERLAPPED in CreateFile() call, as the page http://winprogger.com/multithreaded-synchronous-io-must-be-asynchronous/comment-page-1/#comment-59075 described. This fact haven’t be mentioned in M$’s documentation, and there is few information about this on the web.
Conclusion. If you want to
- Open a handle
- and access it from multiple threads simultaneously
You have to
- Call CreateFile() with FILE_FLAG_OVERLAPPED set
- Call ReadFile() and WriteFile() in overlapped way.
Only when the handle is accessed in overlapped mode, the I/O Manager doesn’t wait for the completion of previous system call. The I/O Manager serialize operations in system call level, on kernel part. So you won’t even see the IRP.