Tried that too…Does not work. This thread’s main functionality is to wait
for notifications from the driver whenever any app in the system sends the
driver a Multicast_IOCTL. So timeout is ruled out. What surprises me is that
my thread does not respond to any other event it is waiting on until the IRP
is completed…
This is what I do…
hEvent[2] , m_ThreadState is global
Main thread:
hEvent[0] = CreateEvent(
NULL, // SD
TRUE, // reset type
FALSE, // initial
state
NULL ); // object
name
hEvent[1] = CreateEvent( NULL, // SD
TRUE, // reset type
FALSE, // initial
state
NULL );
_beginthread(threadfn,0,NULL);
At Cleanup:
m_ThreadState = 1;
SetEvent(hEvent[1]);
threadfn()
{
while(!m_ThreadState){
DeviceIoControl (hFile,
IOCTL_… ,
NULL,0,
buf,buf_size ,
&outbuf_len, &async_over);
if(WaitForMultipleObjects(2,
hEvent,
FALSE,// handle to object
INFINITE // time-out interval
) == WAIT_FAILED)
}
if(m_ThreadState)
{
return;
}
ResetEvent(hEvent[0]);
}
In my driver:
irpList is global;
DISpatch routine…
IoMarkIrpPending(pIrp);
IoSetCancelRoutine(pIrp,CancelRoutine);
InsertTailList(&irpList, &pIrp->Tail.Overlay.ListEntry);
ntStatus = pIrp->IoStatus.Status = STATUS_PENDING;
If(ntStatus != STATUS_PENDING)
IoCompleteRequest( pIrp, IO_NO_INCREMENT );
return ntStatus;
Completion routine…
while (!IsListEmpty(&irpList))
{
pIrp = CONTAINING_RECORD(irpList.Flink, IRP,
Tail.Overlay.ListEntry);
if (IoSetCancelRoutine(pIrp, NULL))
{
//
// It isn’t being cancelled, and can’t be cancelled henceforth.
//
RemoveEntryList(irpList.Flink);
…
pIrp->IoStatus.Status = STATUS_SUCCESS;
IoCompleteRequest( pIrp, IO_NO_INCREMENT );
}
Am I mising something or is there any other way to go about this…
Thanks
DAniel
-----Original Message-----
From: Timothy A. Johns [mailto:xxxxx@driverdev.com]
Sent: Thursday, May 24, 2001 9:03 PM
To: NT Developers Interest List
Subject: [ntdev] Re: Signal a thread?
Daniel,
In addition to the event handle(s) that you created for the overlapped
structure(s), you can also create an additional event to signal when your
application is cleaning up.
The application can WaitForMultipleObjects() or MsgWaitForMultipleObjects()
on the event handle(s) that you created in the overlapped structure(s) as
well as the additional event. When one (or several) of the event(s) are
signalled, you can check to see if it was your ‘cleanup’ event. If not,
then call GetOverlappedResult() with bWait == FALSE to retrieve the results
from that particular event/overlapped call that was signalled.
-Tim
Timothy A. Johns — xxxxx@driverdev.com
Driver Development Corporation — 800.841.0092
Bring Up Your Hardware — Fast. www.driverdev.com
-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com]On Behalf Of Daniel Pradeep
Sent: Thursday, May 24, 2001 6:52 PM
To: NT Developers Interest List
Subject: [ntdev] Re: Signal a thread?
I rewrote my driver to PEnd the IRPs. But still this does not solve the
problem in XP. I have some queries on the working of thread signalling???
I call DeviceIO with overlapped. I then call getOverlapped…And wait for
the event to complete. In driver I pend the IRP, register a cancel routine
and complete it when I get an event. Now the problem I have is,
what happens
if the driver does not get the event to complete the IRP. The thread is
still waiting on Getoverlapped and my app has already called its cleanup
routine…I am puzzled that my app cannot signal the thread it
created…Is this the normal Behaviour or am I missing something
Thanks
Daniel
-----Original Message-----
From: Maxim S. Shatskih [mailto:xxxxx@storagecraft.com]
Sent: Thursday, May 24, 2001 5:43 PM
To: NT Developers Interest List
Subject: [ntdev] Re: Signal a thread?
> I have a DLL that creates a thread which does Overlapped DeviceIOcontrol
to
> my NDIS Miniport driver. My driver does not pend IRPs but waits till the
> respective event occurs and completes them. Now my application
that loaded
> the DLL signals the event that the thread is waiting on. But my thread
does
> not fall through and still waits for the IRP completion from my driver.
How
> do I make my thread respond to the app.
Rewrite the driver to pend the IRPs instead of waiting. This
seems to be the
easiest way.
Max
You are currently subscribed to ntdev as: xxxxx@broadlogic.com
To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com
You are currently subscribed to ntdev as: xxxxx@driverdev.com
To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com
You are currently subscribed to ntdev as: xxxxx@broadlogic.com
To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com
You are currently subscribed to ntdev as: $subst(‘Recip.EmailAddr’)
To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com