While debugging my windows driver, I got a blue screen with error code ATTEMPTED_SWITCH_FROM_DPC,
MS doc says one cannot wait in a DPC:
A wait operation, attach process, or yield was attempted from a DPC routine. This is an illegal operation.
https://docs.microsoft.com/en-us/windows-hardware/drivers/debugger/bug-check-0xb8--attempted-switch-from-dpc
I think it relates to locking a resource with WdfWaitLockAcquire(), which is called in a completion function of a IO request.
MS doc says:
If the driver services the I/O request by creating I/O activity on the device, the driver typically calls WdfRequestComplete from its EvtInterruptDpc or EvtDpcFunc callback function.
https://docs.microsoft.com/en-us/windows-hardware/drivers/wdf/completing-i-o-requests
So the completion function could be called in the DPC context.
I can use spin lock though:
On the other hand, they can acquire and release a driver's executive spin lock with KeAcquireSpinLockAtDpcLevel and KeReleaseSpinLockFromDpcLevel, which run faster than KeAcquireSpinLock and KeReleaseSpinLock.
https://docs.microsoft.com/en-us/windows-hardware/drivers/kernel/guidelines-for-writing-dpc-routines
Subscribe to:
Post Comments (Atom)
Post Code on Blogger
Simplest way to post code to blogger for me: <pre style="background: #f0f0f0; border: 1px dashed #CCCCCC; color: black;overflow-x:...
-
Explain There is not interrupt PIN for PCIe interrupt. When device wants to raise an interrupt, an interrupt message is sent to host via ...
-
Configure Space Addressing One of the major improvements the PCI Local Bus had over other I/O architectures was its configuration mechanism...
-
What is LMA and VMA Every loadable or allocatable output section has two addresses. The first is the VMA, or virtual memory address. This ...
No comments:
Post a Comment