RE: Mutex



Thanks mirage2k2.

i try to use ExAcquireFastMutex(). its works but when i try to unload the
driver it will crash.(Blue screen). Do u have any idea.


"mirage2k2" wrote:

I am not sure because I have not used them and the help is not helpful! I
would guess that the signaled state might change as a result of acquiring and
releasing the mutex ... but I see no acquire function in the help!

I normally wait on event objects - the signaled state is changed using
keSetEvent() and KeResetEvent() ... (the object can also be autoclearing
which is useful)

I have also used fast mutex, they are easy you just call
ExAcquireFastMutex() to attempt to acquire the mutex - if mutex is already
acquired then your thread waits until other thread releases it.


"Hasitha" wrote:

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
.



Relevant Pages

  • Re: [PATCH RFD] alternative kobject release wait mechanism
    ... The next idea is that a driver needs to synchronize its removemethod ... the suspend() method needs to block while readis running. ... First of all I think that I would merge pm and unbind mutex into one - ... thereby preventing autosuspend. ...
    (Linux-Kernel)
  • Re: Fwd: Removing Giant from a driver
    ... pass that mutex instead of Giant... ... I doubt this driver is using a fast interrupt handler... ... A fast interrupt handler doesn't context switch, ... don't understand what Giant is good for. ...
    (freebsd-hackers)
  • Re: iwlagn: associating with AP causes kernel hiccup
    ... there is no much system testing at all for what get's into merging ... This driver has been available and more-or-less working for ages. ... Haven't seen you've filled bug for it. ... I can write a patch to add a mutex and change it to: ...
    (Linux-Kernel)
  • RE: Mutex
    ... I normally wait on event objects - the signaled state is changed using ... I have also used fast mutex, they are easy you just call ... When dma finish his job hi will call interrupt callback function. ... program loop in while loop. ...
    (microsoft.public.development.device.drivers)
  • [Patch RFC 30/37] drivers/base: Convert dev->sem to mutex
    ... The semaphore is used as mutex so make it a mutex. ... ret = device_attach; ... int device_bind_driver ... Manually detach device from driver. ...
    (Linux-Kernel)