Limitations of Overlapped I/O in Windows 95

Last reviewed: September 25, 1995
Article ID: Q125717
The information in this article applies to:
  • Microsoft Win32 Application Programming Interface (API) included with:

        - Microsoft Windows 95 version 4.0
    

SUMMARY

Windows 95 does not support overlapped operations on files, disk, pipes, or mailslots, but does support overlapped operations on serial and parallel communication ports. Non-overlapped file write operations are similar to overlapped file writes, because Windows 95 uses a lazy-write disk cache. Overlapped I/O can be implemented in a Win32-based application by creating multiple threads to handle I/O.

MORE INFORMATION

Asynchronous I/O on files, disk, pipes and mailslots is not implemented in Windows 95. If a Win32-based application running on Windows 95 attempts to perform asynchronous file I/O (such as ReadFile() with any value other than NULL in the lpOverlapped field) on any of these objects, the ReadFile() or WriteFile fails and GetLastError() returns ERROR_INVALID_PARAMETER (87).

Overlapped I/O to serial and parallel communication ports is fully supported in Windows 95. To implement overlapped I/O, call CreateFile() with the FILE_FLAG_OVERLAPPED flag set in the flags attribute.

Overlapped I/O on disk and files was not implemented in Windows 95, because the added performance benefits (which would only affect a certain class of I/O-intensive applications) were not judged to be worth the extra cost.

The system uses a lazy-write disk cache algorithm which automatically provides many of the benefits of overlapped writes. When a process writes data to a file, the data is written to the cache and then the write immediately returns to the calling process. Then, at some later time, the cache manager writes the data to disk. This is similar to behavior that is achieved with overlapped I/O. In the case of disk/file reads, many applications that need to read data do so because it is needed for further processing. Some applications benefit greatly by prefetching data from files while doing other work.

Although Windows 95 does not implement overlapped I/O, it is possible for Win32-based applications on Windows 95 to create additional threads for implementing an effect similar to overlapped file I/O. One way to implement this effect is to communicate with an I/O thread using a request packet mechanism. The thread can queue request packets from other threads and service them as it is able, signalling the other threads on the completion of each request with an event. Even though the application may be "waiting" on some I/O activity, it can still be responsive to the user since the main, or user interface, thread is not blocking on I/O requests. However, the use of multiple threads will increase the amount of time spent in the kernel, which leads to inefficiencies, as compared with an operating system that supports overlapped I/O.

NOTE: Windows NT has a lazy-write disk cache as well. It has been found that a write-back cache is not as good as overlapped I/O, particularly when the data is much larger than the file cache or noncached I/O. One of the biggest benefits of overlapped I/O is that it allows you to quickly get lots of outstanding I/O posted to the disk controller, thereby keeping the disks busy with tagged command queueing in the controller. Using multiple threads is a reasonable substitute, but I/O may be serialized in the filesystem.


Additional reference words: 4.00 95 asynchronous overlapped
KBCategory: kbprg
KBSubcategory: BseFileio


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: September 25, 1995
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.