Windows System Software -- Consulting, Training, Development -- Unique Expertise, Guaranteed Results

Before Posting...
Please check out the Community Guidelines in the Announcements and Administration Category.

More Info on Driver Writing and Debugging

The free OSR Learning Library has more than 50 articles on a wide variety of topics about writing and debugging device drivers and Minifilters. From introductory level to advanced. All the articles have been recently reviewed and updated, and are written using the clear and definitive style you've come to expect from OSR over the years.

Check out The OSR Learning Library at:

Does WDF manages timeout of IO request which is not owned by Driver

remyavu10remyavu10 Member Posts: 58

Driver has a sequential dispatching type read queue. Consider a scenario that driver is busy handling currently dispatched IO read request. Does WDF handles the timeout of IO read requests (overlapped IO operation by application) which are in IO read queue (not owned by driver)?


  • Doron_HolanDoron_Holan Member - All Emails Posts: 10,536
    No. The only request related timeout WDF handles for you is for requests your driver sends to an io target.
  • remyavu10remyavu10 Member Posts: 58
    Ok. Thanks.
    I have further question.

    Suppose application send two overlapped read requests in parallel and wait for 1 sec to finish. These requests shall be received in IO queue (seq queue) and shall be dispatched one by one to driver. Driver took 2 seconds to process one request. Mean time in application side, it get overlapped event timeout for these requests.

    What happened to these IO requests; one is in queue and another is owned by driver?

    Does IO Manager cancel one that in queue?

    What about one IO req owned by driver?
  • Tim_RobertsTim_Roberts Member - All Emails Posts: 13,695

    What happened ...

    Nothing. Think about how this all works. When you say the application "wait for 1 sec to finish", that means the application called WaitForMultipleObjects with a 1 second timeout. That's going to return WAIT_TIMEOUT. That doesn't say ANYTHING about the individual events. It just means the timeout expired before any of the requests completed. The requests are still outstanding, and the application still has to worry about handling them. Usually, the app will just call WaitForMultipleObjects again. Eventually, the requests will complete, either successfully or with a cancellation or a timeout. The application still has to call GetOverlappedResult for the requests that completed.

    Does IO Manager cancel one that in queue?

    IO Manager doesn't know anything about queues. Cancellation is handled by the driver. When a request in on a WDFQUEUE, cancellation is handled by the KMDF code, which is part of the driver.

    Also note that there is no such thing as a "request timeout" from user mode, and you can't cancel individual requests. When the application gets WAIT_TIMEOUT from WaitForMultipleObjects, it certainly has the right to call CancelIo to cancel all requests on the file handle. That sets the "cancel" bit in the IRP, and the driver is supposed to respond by completing the requests with STATUS_CANCELED.

    What about one IO req owned by driver?

    It's the same, except that KMDF isn't going to handle the cancellation automatically. The driver has to check for it and respond.

    "Cancellation" in Windows is really just a suggestion. When an IRP is canceled, that sets a bit in the IRP. That's it. It is entirely up to drivers to figure out how and when to check for that bit, and then complete the request with STATUS_CANCELED. It's not automatic.

    Tim Roberts, [email protected]
    Providenza & Boekelheide, Inc.

  • MBond2MBond2 Member Posts: 210

    It's not just Windows where cancel is a 'suggestion'. Any system at any scale where async operations are issues and can later be cancelled must implement cancel this way. think about it, the call to cancel may occur after the request has been sucessfully processed - just before the caller becomes aware of it

  • remyavu10remyavu10 Member Posts: 58
    Thanks alot for reply.
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Upcoming OSR Seminars
OSR has suspended in-person seminars due to the Covid-19 outbreak. But, don't miss your training! Attend via the internet instead!
Writing WDF Drivers 7 Dec 2020 LIVE ONLINE
Internals & Software Drivers 25 Jan 2021 LIVE ONLINE
Developing Minifilters 8 March 2021 LIVE ONLINE