RE: Mutex

Tech-Archive recommends: Fix windows errors by optimizing your registry



Thankx for the answer.

You will need to change state to not signalled before waiting.
how should i change the state. What kind of command should i use for it.



"mirage2k2" wrote:

The mutex is initialized in the signalled state so your initial wait will not
wait - since object is already signalled.

You will need to change state to not signalled before waiting.


"Hasitha" wrote:

Hi all,
Thank you very much in advance.

I try to use Mutex in my driver program and it does not work as i expect.
I am try to develop driver to PCi device.

In write function write data to dma data buffer and start DAM and lock mutex.
When dma finish his job hi will call interrupt callback function. callback
function will unlock the Meutex.

In init function
KeInitializeMutex(&(pDevEex->Mutex),0);


in Write function

WriteDataToDMA();
StartDMA();
while(1)
{
if((NtStatus = KeWaitForMutexObject(&(pDevEex->Mutex), Executive,
KernelMode, FALSE, NULL)==STATUS_SUCCESS){
break;

}
}


In Interrupt callback function
if(!KeReadStateMutex(&(pDevEex->Mutex)))
KeReleaseMutex(&(pDevEex->Mutex),FALSE);


The problem is function do not wait in KeWaitForMutexObject() function and
program loop in while loop.

What wold be the reason for it.
your corporation is highly appreciated.

With Best Regards

Hasitha
.