Hmm, I thought DIRQL was just short hand for IRQL==DISPATCH_LEVEL in
which case you can use spin locks. However, I could be mistaken.
Anyway, if you are operating at DISPATCH_LEVEL or above, you are running
on a uniprocessor machine, and you enter LockIRQLIndependent while some
other thread is holding the lock, then you are going lock up the system.
The problem is, at DISPATCH_LEVEL or above, threads are not preemptable.
That is, the dispatcher is not going to let any other threads run until
you drop below DISPATCH_LEVEL. You aren’t going to do that until you
acquire the lock. You can’t acquire the lock until some other thread
runs. Dead-lock.
Hope this helps.
Aaron Stavens
NetMotion Wireless, Inc.
-----Original Message-----
From: Mark [mailto:xxxxx@yahoo.com]
Sent: Monday, April 15, 2002 7:32 PM
To: NT Developers Interest List
Subject: [ntdev] InterlockedExchange
Hello,
Had a question regarding InterlockedExchanges. Im at my wits end to find
out what this is all about.
We are basically operating at DIRQL and need to synchronize between
functions running at various IRQLs. Now i know we can use
KeSynch…but…
So…say this is a function I use to synchronize
void LockIRQLIndependent( ULONG *LockVar )
{
while (InterlockedExchange(LockVar ,1) != 0);
}
void UnLockIRQLIndependent( ULONG *LockVar )
{
InterlockedExchange(LockVar , 0);
}
And since I am operating at DIRQL…no spin locks also. So…this does
NOT
work. I still see the two differnt functions entering at the same time.
Also, this seems to be horribly inefficient. So assuming I Cannot use
KeSync and have to use this:
- Is there a more efficient way of using Interlocked…
- Is the above implementation wrong?
Thanks a bunch!
Mark
You are currently subscribed to ntdev as: xxxxx@nmwco.com
To unsubscribe send a blank email to %%email.unsub%%