e-communication masthead image
e-communication logo image
Edition for
September 21, 2004
This newsletter contains archived content. No warranty is made as to technical accuracy of content or currency of URLs.

Overlapped I/O   

Your user-mode application is sending your driver lots of I/O requests, but the driver insists on handling the requests one at a time. What's the problem?

You might think that your driver is blocking in some obscure way or that you need more threads in your application, but the solution is often much simpler: Make sure your application has opened the device for overlapped I/O. Otherwise, the I/O Manager serializes I/O requests by synchronizing through a lock in the file object before dispatching the IRP. Even if your application uses multiple threads, only one request at a time (per file handle) will get through.

To enable overlapped I/O in an application, set dwFlagsAndAttributes with FILE_FLAG_OVERLAPPED when you call CreateFile to open the device. (If you skip this step you won't get overlapped I/O, even if you do everything else right.)

CreateFile returns a handle that can be used to access the device. When you call ReadFile, WriteFile, or DeviceIoControl with the file handle created by CreateFile, supply a pointer to an OVERLAPPED structure that contains a handle to an event object to signal when the operation completes. These functions return immediately for overlapped operations; the event object is signaled when the operation is completed.

Be sure to initialize the OVERLAPPED structure to zero before using it in a function call, and set only the members that are needed by the function. For example, the Offset member should be set for ReadFile and WriteFile calls, but this member should be zero for DeviceIoControl. Also, be sure to use a separate OVERLAPPED structure for each request; re-using the structure before the previous asynchronous operation has been completed can cause errors. Besides, your application will need the original structure to call HasOverlappedIoCompleted or GetOverlappedResult for the request.

After you've opened a device for overlapped I/O, can you simply omit the OVERLAPPED structure to get synchronous I/O? No, you must supply an OVERLAPPED structure for all function calls (read, write, or device control) with that handle. Passing NULL can lead to undefined behavior, even if the driver completes the request synchronously. For synchronous I/O, the OVERLAPPED structure can be declared on the stack as long as the application waits for the I/O to complete before returning.

For code snippets and additional details, read the driver tip on WHDC.


News for Kernel-Mode Developers

WDF on WHDC: Up-to-date Papers, Presentations, and Videos
Microsoft considers the Windows Driver Foundation the key strategy for the next generation of Windows drivers. The WHDC web site features current papers, streaming video of the WDF presentations at WinHEC, and early implementers' experience, plus the invitation to the WDF Beta Program.

Visit WDF on WHDC

Device-Class Tips & News

Guidelines for Audio Device Drivers
These papers are available to guide audio hardware vendors through driver design decisions:

  • Guidelines for choosing how to supply driver support for their audio devices, focusing on drivers that support PCI audio adapters by communicating with the system-supplied PortCls system driver through well-defined device driver interfaces, with a discussion of general hardware requirements for Universal Audio Architecture (UAA) compliance.
    Getting Started with WDM Audio Drivers
  • Guidelines to help vendors ramp up quickly for the new WaveRT (wave real-time) driver model for Windows Longhorn. Microsoft supplies the WaveRT port driver in Portcls.sys, and vendors write their own WaveRT miniport drivers.
    A Wave Port Driver for Real-Time Audio Streaming
  • Guidelines for enhancing drivers for audio devices to play Windows Media® Audio Professional (WMA Pro) audio streams in digital pass-through mode over a Sony/Phillips digital interface format (S/PDIF) link.
    Audio Driver Support for the WMA Pro-over-S/PDIF Format
  • More Audio Device and Driver Guidelines...

    More Device Fundamentals - Overview...

    WinHEC 2005 and Driver DevCon: April in Seattle

    WinHEC 2005: April 25-27, 2005
    Washington State Convention and Trade Center

    Driver DevCon 2005: April 25-28, 2005
    Seattle Sheraton

    Partner participation information for both of these events will be available in November 2004. To receive information when it comes available, please send e-mail to pavilion@microsoft.com.

    Event registration for both WinHEC and Driver DevCon begins in early 2005.

    Windows Platform Directions

    Windows Server 2003 x64 Beta Customer Preview Program
    Sign up now to receive trial software for Windows Server 2003 Enterprise x64 Edition. Read about the Customer Preview Program (CPP) and the different options for obtaining the pre-release software.
    Download Beta Preview

    Microsoft Virtual Server 2005
    Virtual Server 2005 is a new virtual machine solution designed for the Windows Server 2003 platform. Virtual Server 2005 helps increase operational efficiency in software test and development, legacy application re-hosting, and server consolidation scenarios.
    Download an evaluation copy and try it

    Security and Reliability

    Install Critical Updates for Windows and Office
    September's security bulletin release includes critical updates for a buffer overrun vulnerability involving JPEG processing in Windows and Office.
    Security Bulletin and Installation Links

    Changes for Developers in Windows XP SP2

    Microsoft Security Developer Center on MSDN

    More Driver Security and Reliability...

    What else is new on WHDC?

    DDK MVP Expert Zone

    Extreme MVP: If every driver writer would just...

    Insights and Tips from DDK MVPs

    WHDC Ask The Experts

    Windows Kernel Plug and Play and Power Management
    October 20, 2004
    17:00-18:00 GMT

    Details for WHDC Ask the Experts

    Resources for Developers

    Debugging Tools for Windows - Version 6.3.17.0

    Which DDK and HCT to Use?

    KB Articles for the DDK

    Events and Errors Message Center


    To cancel your subscription to this newsletter, reply to this message with the word UNSUBSCRIBE in the Subject line. You can also unsubscribe at http://www.microsoft.com/misc/unsubscribe.htm. You can manage all your Microsoft.com communication preferences at this site.

     Legal Information.

    This newsletter was sent by the Microsoft Corporation
    1 Microsoft Way
    Redmond, Washington, USA
    98052

    Sign up for other newsletters | Unsubscribe | Update your profile
    © 2004 Microsoft Corporation Terms of Use | Privacy Statement
    Microsoft