Immediate IO in ReadFile / WriteFile

Martin Wilck Martin.Wilck at fujitsu-siemens.com
Wed Jan 9 05:44:04 CST 2002


Hi Mike,

I just had the following thought on the immediate IO in ReadFile() /
WriteFile() that you implemented:

Consider the following situation:

1. There is no data available for reading on some fd (serial port, pipe,
   socket).
2. An application calls ReadFile() in overlapped mode.
   since no data is there, an overlapped request is scheduled.
3. Data becomes available before the app issues a wait request of any
   kind.
4. The application starts another ReadFile() request.
   Now data is there, and will be read immediately.
   No async request is scheduled.
5. Eventually, more data will become available, and the async request
   first scheduled will also return.

However, this basically destroys the order of the requests.
I am unsure how Windows would behave in such a case, and it is certainly
difficult to provide a test case for this situation. It can occur, though,
and my guess is this is the wrong behaviour.

Thus, probably before doing the immediate read it should be checked
if there are asynchronous requests already scheduled for reading,
and if yes, ReadFile() should _not_ try to read immediately but go
pending. Of course, this check would require a server call.

The same reasoning applies for writing, of course.

Things become even more confusing if you think of several threads
reading from the same file.

A very simple workaround would be to go pending unconditonally for
overlapped requests. Although not optimal, this would be certain
not to corrupt data.

What do you think?

Martin

-- 
Martin Wilck                Phone: +49 5251 8 15113
Fujitsu Siemens Computers   Fax:   +49 5251 8 20409
Heinz-Nixdorf-Ring 1	    mailto:Martin.Wilck at Fujitsu-Siemens.com
D-33106 Paderborn           http://www.fujitsu-siemens.com/primergy









More information about the wine-devel mailing list