none
How a driver can handle request from user mode asynchronously RRS feed

  • Question

  • I have created a queue successfully and the queue dispatch type is WdfIoQueueDispatchParallel. my user app is sending data via deviceiocontrol with an overlap structure but I want to know if its really necessary to complete the request imemdiatley without forwarding to second queue or i have to forward to a second queue because I also have a timer with a timer function callback which can complete the pending requests from second queue(whose dispatch type is wdfioQueueDispatchManual) so which is best forward to the second queue or complete immediately.

    if I complete immediately does the user app get blocked irregardless of sending request with an overlap and what if I my second queue just use the WdIoQueueDispatchParallel does it process the request faster since the period of my timer is 10 ms



    • Edited by davescxp Sunday, March 5, 2017 6:04 AM
    Sunday, March 5, 2017 6:00 AM

All replies

  •  I want to know if its really necessary to complete the request imemdiatley without forwarding to second queue or i have to forward to a second queue because I also have a timer 

    If your app can produce data very fast, it can overflood the kernel part. Then you need to create "back pressure" on the app by pending requests until they are actually completed. On the other hand, if the app sends short bursts of data but the average rate is steady, you may prefer to buffer the data on the kernel side and release the app immediately. Or mix these two tactics (have a fixed size queue).

    --pa

    Sunday, March 5, 2017 3:07 PM
  • The rule is that once your driver receives a request/IRP, you own it and you can do whatever you want with it, including completing them in any order and at any time.

    Threads issuing asynchronous I/O requests never block waiting for an I/O request to complete. However, when you issue an I/O request, such as ReadFile, WriteFile, or DeviceIoControl, the thread transitions to kernel-mode and the beginning of the request is processed on that thread in the driver, until the driver decides to either queue the request or complete it.

    When the driver completes a request, it specifies a priority boost (the value of the boost is generally a function of how long the I/O took to complete, e.g. slower devices get higher boosts, with the exception being devices that cannot tolerate long latencies, such as sound).

     -Brian


    Azius Developer Training www.azius.com Windows device driver, internals, security, & forensics training and consulting. Blog at www.azius.com/blog

    Sunday, March 5, 2017 6:03 PM
    Moderator