IoQueueWorkItem priorities



The work items are being called out of the expected order in XP.

I have a filter driver that captures Read/Write events during a call to
IRP_MJ_INTERNAL_DEVICE_CONTROL. In this function I create a worker's
thread with IoQueueWorkItem(), call it Callback_1, so I can store the
information in a buffer that is locked with ExAcquireFastMutex().

In the completion routine for the corresponding Read/Write event, I
also create a worker's thread with IoQueueWorkItem(), call it
Callback_2, where the completion information is also stored in the same
buffer locked with ExAcquireFastMutex. Both calls to
IoQueueWorkItem(), I use CriticalWorkQueue.

Under streneous tests with tons of Read/Write events, there is a case
where Callback_2 is called before Callback_1. According to the DDK
documentation, the callbacks can be preempted according to thread
priority. Is the completion thread higher than the request thread?

What would you suggest as a solution to always guarantee Callback_1 to
be called before Callback_2. Change CriticalWorkQueue for Callback_2
to DelayedWorkQueue?

.