waiting in kernel thread

I have tis problem, one function that can be called several times but always block in a event object, when i need to release the threads sometimes the order would be diferent that the arrival order.
I see something similar in a vxd with a thread waiting in an identifier, and then you decided wich thread willl be free with the identifier.
Thanks in advance.

On Dec 6, 2006, at 10:07 PM, xxxxx@yahoo.com wrote:

I have tis problem, one function that can be called several times
but always block in a event object, when i need to release the
threads sometimes the order would be diferent that the arrival order.

This is just how it works. Why are you waiting? Can you perhaps pend
your IRP in a CSQ and return pending? Then things would come out “in
order”.

Note that “order” is a dangerous way to think about things; you can’t
control what order you get called in by the kernel if the threads are
at < DISPATCH_LEVEL, which they obviously are if you can legally be
waiting on them in the first place.

The scheduler can re-order things between the time your client app or
upper driver creates the I/O request and the time that you actually
get it. Point being - you have to step back and ask yourself why you
care that things arrive and leave “in order”; you probably don’t.

-sd

I need something similar to IFSMgr_Block(thread_identifier) and IFSMgr_Wakeup(thread_identifier) for an nt driver.

but not for a file system driver

Keep a list of events and have a 1:1 relationship between KEVENT and thread.

Each thread declares a struct { KEVENT Event; LIST_ENTRY Entry; } on the stack
Init the struct
Insert it into some list
Wait on the event

Some other entity walks the list, pops an entry off and then sets the event.

You still haven’t answered why you need to do this. I bet there is a simpler way if you just explain what you are trying to do from a more abstract level.

d

You have each thread block on its own event, and save a list of events &
thread IDs in your driver. When the waking agent wants to wake a
particular thread it walks the list, finds that thread’s event and
signals only that event.

The waiting thread can place the structure containing the event, the
list entry & the thread ID on its own stack, as long as you don’t allow
the structure to go out of scope before you call or return from
KeWaitForSingleObject.

-p

xxxxx@yahoo.com wrote:

I need something similar to IFSMgr_Block(thread_identifier) and
IFSMgr_Wakeup(thread_identifier) for an nt driver.


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

To unsubscribe, visit the List Server section of OSR Online at
http://www.osronline.com/page.cfm?name=ListServer