Can I call KeAcquireSpinLockAtDpcLevel at DISPATCH_LEVEL?
- From: 0dbell@xxxxxxxxx
- Date: Sun, 10 Jun 2007 12:03:26 -0700
Can I call KeAcquireSpinLockAtDpcLevel at DISPATCH_LEVEL?
While this question may sound silly (since the function name suggests
that it is made exactly for acquiring a spinlock at DISPATCH_LEVEL),
you will shortly find out why I am asking it:
In the book that I am using to learn the art of writing WDM device
drivers (by Chris Cant, published by R&D books), the section on Spin
Locks reads:
"Only one instance of a piece of code can acquire a spin lock at the
same time. Other attempts to acquire the spin lock will "spin" until
the resource becomes available. "Spinning" means that
KeAcquireSpinLock keeps looking continuously. ... If you are certain
that your code is working at DISPATCH_LEVEL, you can use
KeAcquireSpinLockAtDpcLevel ... for better performance."
However, in Microsoft's list of "Tips for Windows NT Driver Developers
-- Things to Avoid":
http://support.microsoft.com/default.aspx?scid=KB;EN-US;Q186775&
tips #6 and #7 read:
6. Never wait on a kernel dispatcher object for a nonzero interval at
IRQL >= DISPATCH_LEVEL. It is a fatal error.
7. Never call any function that causes the calling thread to wait
directly or indirectly while executing at IRQL >= DISPATCH_LEVEL. It
is a fatal error.
Now I am confused: is a SpinLock considered a "kernel dispatcher
object"? If so, which piece of information (of the two brought above)
is correct?
If SpinLocks are not considered "kernel dispatcher objects", could you
please explain the difference? What is considered to be a "kernel
dispatcher object"? After all, a piece of code attempting to acquire a
spinlock will wait indefinitely until it is release, right? (I know
about the 25 microsecond max acquisition rule).
To further deepen my confusion, Microsoft's MSVAD sample (tested
working perfectly in a multi-processor system) definitely calls
KeAcquireSpinLockAtDpcLevel inside a TimerNotify DPC (see
CSaveData::WriteData):
http://msdn2.microsoft.com/en-us/library/ms790032.aspx
So it seems that either tips #6 and #7 are incorrect/inaccurate or...
a spinlock is not a "kernel dispatcher objects"?
If the latter, what makes the wait on spinlock so different from a
wait on a "kernel dispatcher objects" that makes it suitable for
DISPATCH_LEVEL?
Could someone clarify this issue(s) please?
Thanks,
Don
.
- Follow-Ups:
- RE: Can I call KeAcquireSpinLockAtDpcLevel at DISPATCH_LEVEL?
- From: Anton Bassov
- Re: Can I call KeAcquireSpinLockAtDpcLevel at DISPATCH_LEVEL?
- From: Maxim S. Shatskih
- Re: Can I call KeAcquireSpinLockAtDpcLevel at DISPATCH_LEVEL?
- From: Don Burn
- RE: Can I call KeAcquireSpinLockAtDpcLevel at DISPATCH_LEVEL?
- Prev by Date: Re: usb how to...
- Next by Date: Re: Can I call KeAcquireSpinLockAtDpcLevel at DISPATCH_LEVEL?
- Previous by thread: usb how to...
- Next by thread: Re: Can I call KeAcquireSpinLockAtDpcLevel at DISPATCH_LEVEL?
- Index(es):
Relevant Pages
|