Calling worker thread from dispatch routine

When I get a IRP_MJ_DIRECTORY_CONTROL in my dispatch
routine I create a context structure that contains:

  • the irp pointer
  • a pointer to the current stack location
  • a pointer the the device
    I initialize (ExInitializeWorkItem) and queue the work
    item (ExQueueWorkItem). Then I mark the irp as
    pending and return STATUS_PENDING.

When my routine is called by the worker thread I
simply:
/*****************************************
//
// Copy parameters down to next level in the
// stack for the driver below us
//
nextIrpStack = IoGetNextIrpStackLocation(
pData->srcIRP);
*nextIrpStack = *pData->currentIrpStack;

//
// Set no completion routine
//
IoSetCompletionRoutine( pData->srcIRP,
HookDone, NULL, FALSE, FALSE, FALSE );

//
// Call down
//
IoCallDriver( pData->deviceObject, pData->srcIRP );

ExFreePool(pData);
**********************************/

I realize that there are newer routines for queueing
and init-ing work items, but I’d like this to work on
NT 4.

The problem is that the system hangs in very short
order. No bluescreens, just stops responding.

Thanks for any pointers.

Randy Cook
Lucid Systems Inc.


Do you Yahoo!?
HotJobs - Search new jobs daily now
http://hotjobs.yahoo.com/

The comment says to not set a completion routine, but you set HookDone()
with all options set to false. Why? I would also recommend the marking of
the IRP as pending before you queue the work item. On a SMP system, another
CPU could being processing the IRP before your routine can resume execution.

----- Original Message -----
From: “Randy Cook”
To: “File Systems Developers”
Sent: Wednesday, October 30, 2002 1:56 PM
Subject: [ntfsd] Calling worker thread from dispatch routine

> When I get a IRP_MJ_DIRECTORY_CONTROL in my dispatch
> routine I create a context structure that contains:
> - the irp pointer
> - a pointer to the current stack location
> - a pointer the the device
> I initialize (ExInitializeWorkItem) and queue the work
> item (ExQueueWorkItem). Then I mark the irp as
> pending and return STATUS_PENDING.
>
> When my routine is called by the worker thread I
> simply:
> /*****************************************
> //
> // Copy parameters down to next level in the
> // stack for the driver below us
> //
> nextIrpStack = IoGetNextIrpStackLocation(
> pData->srcIRP);
> nextIrpStack = pData->currentIrpStack;
>
> //
> // Set no completion routine
> //
> IoSetCompletionRoutine( pData->srcIRP,
> HookDone, NULL, FALSE, FALSE, FALSE );
>
> //
> // Call down
> //
> IoCallDriver( pData->deviceObject, pData->srcIRP );
>
> ExFreePool(pData);
>
********************************/
>
> I realize that there are newer routines for queueing
> and init-ing work items, but I’d like this to work on
> NT 4.
>
> The problem is that the system hangs in very short
> order. No bluescreens, just stops responding.
>
> Thanks for any pointers.
>
> Randy Cook
> Lucid Systems Inc.
>
> __________________________________________________
> Do you Yahoo!?
> HotJobs - Search new jobs daily now
> http://hotjobs.yahoo.com/
>
>
> —
> You are currently subscribed to ntfsd as: xxxxx@yoshimuni.com
> To unsubscribe send a blank email to %%email.unsub%%

Thanks David,

Marking the IRP as pending before queueing the item
did the trick. The IRP was being completed by the
worker thread before it was being marked as pending
(even on a single cpu machine).

The code:

IoSetCompletionRoutine( pData->srcIRP,
HookDone, NULL, FALSE, FALSE, FALSE );

is a remnant of some sample code that I looked at.

— “David J. Craig” wrote:
> The comment says to not set a completion routine,
> but you set HookDone()
> with all options set to false. Why? I would also
> recommend the marking of
> the IRP as pending before you queue the work item.
> On a SMP system, another
> CPU could being processing the IRP before your
> routine can resume execution.
>
> ----- Original Message -----
> From: “Randy Cook”
> To: “File Systems Developers”
> Sent: Wednesday, October 30, 2002 1:56 PM
> Subject: [ntfsd] Calling worker thread from dispatch
> routine
>
>
> > When I get a IRP_MJ_DIRECTORY_CONTROL in my
> dispatch
> > routine I create a context structure that
> contains:
> > - the irp pointer
> > - a pointer to the current stack location
> > - a pointer the the device
> > I initialize (ExInitializeWorkItem) and queue the
> work
> > item (ExQueueWorkItem). Then I mark the irp as
> > pending and return STATUS_PENDING.
> >
> > When my routine is called by the worker thread I
> > simply:
> > /*****************************************
> > //
> > // Copy parameters down to next level in the
> > // stack for the driver below us
> > //
> > nextIrpStack = IoGetNextIrpStackLocation(
> > pData->srcIRP);
> > nextIrpStack = pData->currentIrpStack;
> >
> > //
> > // Set no completion routine
> > //
> > IoSetCompletionRoutine( pData->srcIRP,
> > HookDone, NULL, FALSE, FALSE, FALSE );
> >
> > //
> > // Call down
> > //
> > IoCallDriver( pData->deviceObject, pData->srcIRP
> );
> >
> > ExFreePool(pData);
> >
********************************/
> >
> > I realize that there are newer routines for
> queueing
> > and init-ing work items, but I’d like this to work
> on
> > NT 4.
> >
> > The problem is that the system hangs in very short
> > order. No bluescreens, just stops responding.
> >
> > Thanks for any pointers.
> >
> > Randy Cook
> > Lucid Systems Inc.
> >
> >
> > Do you Yahoo!?
> > HotJobs - Search new jobs daily now
> > http://hotjobs.yahoo.com/
> >
> >
> > —
> > You are currently subscribed to ntfsd as:
> xxxxx@yoshimuni.com
> > To unsubscribe send a blank email to
> %%email.unsub%%
>
>
>
>
> —
> You are currently subscribed to ntfsd as:
> xxxxx@yahoo.com
> To unsubscribe send a blank email to
%%email.unsub%%


Do you Yahoo!?
HotJobs - Search new jobs daily now
http://hotjobs.yahoo.com/