UMDF Host timeouts

In my UMDF2.0, i am handling read, write inside of the IO Callbacks. This handling include wait for timeouts as well (waiting means handling timeout value set using SetCommTimeouts API).

#1. I would ask waiting inside IO Callbacks during read/write/control causes any Host Process Timeouts and device driver restarts?

waiting inside IO Callbacks during read/write/control causes any Host Process Timeouts…

PROBABLY not. But it’s almost always a Very Bad Idea. When you wait, you’re blocking an arbitrary thread from making progress. If you’re blocking a WDF worker thread (for example), that could be bad… because it’s not available to initiate other work (on your driver, or other UMDF drivers).

There’s absolutely no reason for you to do this. If you need to handle SetCommTimeouts just start a timer when you initiate the Request and stop that timer when the Request completes. If the timer fires, complete the I/O Request that you have in progress that’s associated with that timer (with whatever status you want).

So… Do The Right Thing. Get a Request, start a timer, make the Request active, and then return from the EvtIo Event Processing Callback.

Peter

1 Like

Ok Thank you for suggestion.
So, i hope, it can create separate timer for each request category (read, write, or control) for handling timeouts for each.

i hope, it can create separate timer for each request category

Of course it (er, YOU) can. You know… just create three different fields in your WDFDEVICE Context (Context->ReadTimer, Context->WriteTimer, Context->IoctlTimer) or whatever you want. It’s just a timer.

Peter

Ok thanks