none
How to wait on a WDF collection ? RRS feed

  • Question

  • Hi Experts:

    I'm working with a usb touch filter driver, collecting touch points and return to the user mode apps (which calls the driver in a "while" loop using DeviceIOControl). I store the touch points in an WDF collection, and return one point each time when the user app calls.

    My question is:

    If there is no touch points in the collection, how do I wait and only return to user mode app call when there is touch points in the collection; this way, I do not return constantly to the user mode app with empty points.

    Also, if I use a regular data buffer, not the WDF collection, will that be faster ?

    Thanks for your oppinion.

    Polaris

    Saturday, October 27, 2012 5:13 AM

Answers

  • Typically for this, you create a manual queue in you EvtAddDevice code to store pended requests.  So your logic becomes in you device IO control handler:

         if collection not empty grab a touch point and complete the request

         else put request in the manual queue

    When you get a touch point you logic is

         if manual queue not empty get request to return touch point and complete

         else put touch point in collection


    Don Burn Windows Filesystem and Driver Consulting Website: http://www.windrvr.com Blog: http://msmvps.com/blogs/WinDrvr

    Saturday, October 27, 2012 11:29 AM
  • If there is no pending request that could indicate, that the application hasn't had a chance to process the last touch point and return the IOCTL.  Even if you have the application use OVERLAPPED I/O and a bunch of requests this is possible.

    I don't know enough about what you are doing to understand if you need seperate IOCTL's.  You could also just key it on the application opening and closing the device.


    Don Burn Windows Filesystem and Driver Consulting Website: http://www.windrvr.com Blog: http://msmvps.com/blogs/WinDrvr

    • Marked as answer by Polaris510 Sunday, October 28, 2012 4:26 PM
    Sunday, October 28, 2012 11:15 AM

All replies

  • Typically for this, you create a manual queue in you EvtAddDevice code to store pended requests.  So your logic becomes in you device IO control handler:

         if collection not empty grab a touch point and complete the request

         else put request in the manual queue

    When you get a touch point you logic is

         if manual queue not empty get request to return touch point and complete

         else put touch point in collection


    Don Burn Windows Filesystem and Driver Consulting Website: http://www.windrvr.com Blog: http://msmvps.com/blogs/WinDrvr

    Saturday, October 27, 2012 11:29 AM
  • what don said, but make sure you are holding a spinlock why doing the operations so that they are atomic across the queue and collection checks/changes

    d -- This posting is provided "AS IS" with no warranties, and confers no rights.

    Saturday, October 27, 2012 3:04 PM
  • Thanks for your suggestions Donald.

    My questoin: for the 2nd part in your reply (when I get a touch point logic): if there is no pending request, that would indicate there is no user app is calling, so seems no need to add the touch point into the collection, is it correct ?  Or do I need to implement another IOCTL for the user mode app to signaling the "start" and "stop" of the touch point collecing process (which means, the driver will keep putting points into the collection until the user mode app sending a "stop" ioctl)?

    Sunday, October 28, 2012 6:11 AM
  • If there is no pending request that could indicate, that the application hasn't had a chance to process the last touch point and return the IOCTL.  Even if you have the application use OVERLAPPED I/O and a bunch of requests this is possible.

    I don't know enough about what you are doing to understand if you need seperate IOCTL's.  You could also just key it on the application opening and closing the device.


    Don Burn Windows Filesystem and Driver Consulting Website: http://www.windrvr.com Blog: http://msmvps.com/blogs/WinDrvr

    • Marked as answer by Polaris510 Sunday, October 28, 2012 4:26 PM
    Sunday, October 28, 2012 11:15 AM
  • Thanks Donald!
    Sunday, October 28, 2012 4:27 PM