Hi All,
I was accidentally calling the function WDFRequestComplete while holding a spin lock in my driver and it was causing a system freeze under certain situations. After connecting the debugger i was seeing an assert message that “DPC watch dog timer expired!”
I read in one of the OSR posts that this is not a valid coding practice. Could somebody please enlighten me what exactly happens in the system if i call WDFRequestComplete while holding a spin lock and how can that lead to a DPC timer getting expired?
I would like to get deeper understanding about how Windows works in the above scenario rather than blindly following the coding practice.
>enlighten me what exactly happens in the system if i call WDFRequestComplete while holding a spin
lock
WDFRequestComplete will call the completion routines in the upper driver(s), which sometimes can (allowed) to send some other IRPs to your driver from top.
Then your driver’s dispatch routine tries to acquire the spinlock which is already acquired.
It is a good idea to avoid calls out of the binary (to other drivers) while holding a lock.
–
Maxim S. Shatskih
Microsoft MVP on File System And Storage
xxxxx@storagecraft.com
http://www.storagecraft.com
It’s valid… It’s just not a best practice.
You want to minimize the time you spend holding a spin lock. The I/O completion path can be long. So, bad idea to hold a spin lock while running an arbitrarily long code path.
AND what Max said.
Peter
OSR
@OSRDrivers