Interlocked exchange again!

I wrongly mentioned that both functions enter at the same time…god knows what I was thinking:)

So here is the problem again:

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);
}

It actually locks up. What we are trying to do is to synchronize all miniport entry points with an external function callback. So the IRQL is raised and then the external function tries to acquire the lock. In addition, the miniport entry points also try to acquire the same (inter) lock. We cannot use KeSync because there is no way to get the interrupt object of the port driver. So looks like I have my understanding of Interlocked stuff all wrong? Can you guys please help?

TIA

Mark


Do You Yahoo!?
Yahoo! Tax Center - online filing with TurboTax

Carefully read Jake Oshins reply later on. It has a WEALTH of information. Do you developed the port driver? If so then the port driver entry points can be modified to call KSE. If the port driver source is not controlled by you then as Jake mentioned you’re primary alternative is the use of the single linked and doubly linked list calls such as ExInterlockedRemove/InsertEntryList. The tricks is that you ONLY use the ExInterlockedXxxx function calls to access your lists, and the spinlock associated with the lists is dedicated to control access to the list.


Gary G. Little
xxxxx@broadstor.com
xxxxx@inland.net
“Mark Lobo” wrote in message news:xxxxx@ntdev…

I wrongly mentioned that both functions enter at the same time…god knows what I was thinking:)

So here is the problem again:

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);
}

It actually locks up. What we are trying to do is to synchronize all miniport entry points with an external function callback. So the IRQL is raised and then the external function tries to acquire the lock. In addition, the miniport entry points also try to acquire the same (inter) lock. We cannot use KeSync because there is no way to get the interrupt object of the port driver. So looks like I have my understanding of Interlocked stuff all wrong? Can you guys please help?

TIA

Mark

------------------------------------------------------------------------------
Do You Yahoo!?
Yahoo! Tax Center - online filing with TurboTax