|
1,《Network Programming for Microsoft Windows /2nd ed》第5.2 Socket I/O Models中有一段
All overlapped operations are guaranteed to be executed in the order that the application issued them. However, the
completion notifications returned from a completion port are not guaranteed to be in that same order.
2,《windows via c++》(windows核心编程第5版)第10.5 Basics of Asynchronous Device I/O
Asynchronous Device I/O Caveats
You should be aware of a couple of issues when performing asynchronous I/O. First, the device driver doesn't have to process
queued I/O requests in a first-in first-out (FIFO) fashion. For example, if a thread executes the following code, the device
driver will quite possibly write to the file and then read from the file:
OVERLAPPED o1 = { 0 };
OVERLAPPED o2 = { 0 };
BYTE bBuffer[100];
ReadFile (hFile, bBuffer, 100, NULL, &o1);
WriteFile(hFile, bBuffer, 100, NULL, &o2);
A device driver typically executes I/O requests out of order if doing so helps performance. For example, to reduce head
movement and seek times, a file system driver might scan the queued I/O request list looking for requests that are near the
same physical location on the hard drive.
综合以上两种说法,貌似有点矛盾。我暂时只能这么理解:
read和write之间可能会打乱顺序,但是read和read之间,write和write之间的相对顺序是可以确保的。(比如socket对于read和write有不同的buffer) |
|