RE: [NTDEV] Spinlocks in NDIS Drivers

Spin lock routines generates three critical actions:

  1. KeBugCheck(IRQL_NOT_GREATER_OR_EQUAL)
  • in KfAcquireSpinLock when KeGetCurrentIrql() > DISPATCH_LEVEL
  • in KfReleaseSpinLock when NewIrql > KeGetCurrentIrql()
  1. KeBugCheck(SpinLock)
  • in Kii386SpinOnSpinLock (called from KfAcquireSpinLock when
    spin lock is already acquired) if current thread has the spin lock
    already acquired
  • in KfReleaseSpinLock if the spin lock is not acquired by current thread
  1. hardcoded breakpoint (int 3)
  • in Kii386SpinOnSpinLock when spinning for too long

Spin lock can be acquired only once and also released only once.
If you try to acquire spin lock when you already have it it is programmer’s
error.
Also if you try to release spin lock which you have not acquired.

Paul

-----P?vodn? zpr?va-----
Od: Ajitabh Prakash [SMTP:xxxxx@future.futsoft.com]
Odesl?no: 18. kv?tna 2000 15:33
Komu: NT Developers Interest List
P?edm?t: [ntdev] [NTDEV] Spinlocks in NDIS Drivers

hi all,

I was just thinking that what will actually happen if the same
thread
tries to acquire the spin lock twice.??? Can the spinlock be acquired
twice
by tha same thread.I understand that it not logically right to acquire the

spinlock twice but in huge bulcky codes it could be a possibility that the

same spin lock may be acuired twice.

In case of two threads trying to acquire the spin lock One thread will
wait
if the spinlock is already acquired by other thread. But what will happen
in the above case.

Thanks
Ajitabh


You are currently subscribed to ntdev as: xxxxx@sodatsw.cz
To unsubscribe send a blank email to $subst(‘Email.Unsub’)