Hi Folks,
I am looking to create a mutex on a struct for a kernel device driver.
>From the DDK it says you need KeInitializeMutex() but I was wondering
how you initialize the mutex on the struct.

KMUTEX mutex;
KeInitializeMutex(&mutex,0);

Where does the structure get allocated?

Thanks in advance for the help,
Cheers,
Con

Re: KeInitializeMutex on a struct by conjonh

conjonh
Fri Oct 14 04:11:28 CDT 2005

Folks,

Forgot to say I have created memory for the struct as so:
queuedWorkItem = ExAllocatePool(NonPagedPool,
sizeof(strQueuedWorkItem));

Con


Re: KeInitializeMutex on a struct by Skywing

Skywing
Fri Oct 14 10:44:21 CDT 2005

You are allocating the memory yourself by declaring the KMUTEX variable.

"conjonh" <con.brady@gmail.com> wrote in message
news:1129280361.043866.232750@g47g2000cwa.googlegroups.com...
> Hi Folks,
> I am looking to create a mutex on a struct for a kernel device driver.
>>From the DDK it says you need KeInitializeMutex() but I was wondering
> how you initialize the mutex on the struct.
>
> KMUTEX mutex;
> KeInitializeMutex(&mutex,0);
>
> Where does the structure get allocated?
>
> Thanks in advance for the help,
> Cheers,
> Con
>



Re: KeInitializeMutex on a struct by conjonh

conjonh
Fri Oct 14 11:13:38 CDT 2005

So how do I reference this memory allocated by the KMUTEX to link to
the structure I want the mutex on?

Cheers,
Con


Re: KeInitializeMutex on a struct by Skywing

Skywing
Fri Oct 14 12:43:43 CDT 2005

struct thing {
PKMUTEX mutex;
};

or perhaps you would store it in the struct body itself, depending on the
situation.

struct thing {
KMUTEX mutex;
};

"conjonh" <con.brady@gmail.com> wrote in message
news:1129306418.376747.314510@g14g2000cwa.googlegroups.com...
> So how do I reference this memory allocated by the KMUTEX to link to
> the structure I want the mutex on?
>
> Cheers,
> Con
>



Re: KeInitializeMutex on a struct by Maxim

Maxim
Tue Oct 18 18:34:48 CDT 2005

On the stack. Sometimes it is a bad idea, if you will need to return from
this function while holding the mutex.

--
Maxim Shatskih, Windows DDK MVP
StorageCraft Corporation
maxim@storagecraft.com
http://www.storagecraft.com

"conjonh" <con.brady@gmail.com> wrote in message
news:1129280361.043866.232750@g47g2000cwa.googlegroups.com...
> Hi Folks,
> I am looking to create a mutex on a struct for a kernel device driver.
> >From the DDK it says you need KeInitializeMutex() but I was wondering
> how you initialize the mutex on the struct.
>
> KMUTEX mutex;
> KeInitializeMutex(&mutex,0);
>
> Where does the structure get allocated?
>
> Thanks in advance for the help,
> Cheers,
> Con
>