Different between WDFSPINLOCK and WDFWAITLOCK

I’m very confused the different between WDFSPINLOCK and WDFWAITLOCK, I thought they may be nearly. But when I use it in USB interrupt pipe, if WDFWAITLOCK, the OS will crash, if
WDFSPINLOCK it can be OK, Is there anyone know the reason and explain it?

What IRQL are you running at? I just checked the specs for WDFWAITLOCK
(using the RTFM model for achieving understanding) and they clearly state
that you must be running < DISPATCH_LEVEL. WDFSPINLOCK clearly states
that it is permissible at <= DISPATCH_LEVEL. That is, at some level, all
the information you need.

Note that “The OS will crash” is an extremely useless piece of
information. If you do not provide the !analyze -v output, it sort-of
tells us that you never bothered to find out what was wrong, and if you
had, you would not have had to ask this question.

I suspect that a WDFWAITLOCK is implemented by a KMUTEX “under the floor”,
and WDFSPINLOCK is implemented by a KSPIN_LOCK, in which case, if the
difference is now not obvious to you, I suggest you read the article on
kernel synchronization which is linked to by the descriptions of these
objects.

As a driver writer, you MUST (not optional) understand the synchornization
primitives, what they are doing, what IRQLs they can run at, what their
timing constraints and IRQLs are (for example, for a WDFSPINLOCK tells
you that after the KdfSpinLockAcquire call, your thread is now executing
at DISPATCH_LEVEL. You need to know this.

When in doubt, RTFM.
joe

I’m very confused the different between WDFSPINLOCK and WDFWAITLOCK, I
thought they may be nearly. But when I use it in USB interrupt pipe, if
WDFWAITLOCK, the OS will crash, if
WDFSPINLOCK it can be OK, Is there anyone know the reason and explain it?


NTDEV is sponsored by OSR

Visit the list at: http://www.osronline.com/showlists.cfm?list=ntdev

OSR is HIRING!! See http://www.osr.com/careers

For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars

To unsubscribe, visit the List Server section of OSR Online at
http://www.osronline.com/page.cfm?name=ListServer

Thank you for your response. I check the IRQL = 2(DISPATCH_LEVEL) , And this cause the error.