Spin lock question

Hi,

My understanding is that if you run at DISPATCH level, the scheduler will not preempt your thread for another thread, but you can still be pre-empted by an ISR. Right? If this is the case, do spin locks work between an ISR and a dispatch level thread running on the same processor? Seems to me if dispatch level thread A grabs a spin lock, then is pre-empted by ISR B, if ISR B tries to grab the spin lock it will spin forever.

Is my assumption wrong.

Thanks,

This question is better asked on NTDEV…

My understanding is that if you run at DISPATCH level, the scheduler will
not preempt your thread for another thread, but you can still be
>pre-empted by an ISR.

Yes, you can be *interrupted* by an ISR (pre-emption implies a change in
thread context, interrupts use the current thread’s execution context).

If this is the case, do spin locks work between an ISR and a dispatch level
thread running on the same processor?

Executive spinlocks (KeAcquireSpinlock) and queued spinlocks
(KeAcquireInStackQueuedSpinLock) can not be used to serialize between code
running at DIRQL and code running at DISPATCH_LEVEL because of the problem
you are describing. Interrupt spinlocks, however, can be used for
serialization in this case because they raise to DIRQL before acquiring. See
KeAcquireInterruptSpinLock.

-scott


Scott Noone
Consulting Associate and Chief System Problem Analyst
OSR Open Systems Resources, Inc.
http://www.osronline.com