RE: What if Unload routine releases a resource that DPC r- outine uses later?

Use Spin Lock(If you do not care about performance) or count (With
Interloceked Incrments/Decrements) to indicate the number of
executing DPC’s. On a Quad you could have your DPC executing on
three processors at the same time. In unload mark the driver being
unloaded and wait till all the DPC’s are executed. Once the driver
is marked unloaded do not queue any more DPC’s.

-Srin.

-----Original Message-----
From: Christopher Marcos [mailto:xxxxx@juno.com]
Sent: Thursday, September 27, 2001 3:07 PM
To: NT Developers Interest List
Subject: [ntdev] What if Unload routine releases a resource that DPC
routine uses later?

I would like to have the driver, which has not yet been opened by any
application, enable interrupts on a board to detect for overheating.

Is it possible for the system, upon receiving a “net stop driver” command
from the user, to call a driver’s Unload routine when there is a queued
DPC or
when a DPC routine is being executed?

If it is possible, I don’t see any way to prevent a DPC routine
from using a resource, such as a synchronization object,
that may have already been released by a concurrent execution
of the Unload routine.

I’m trying to make my driver multi-processor safe, and would like
to safeguard against the following scenario:

The driver is running on two processors. Processor 1 dequeues
the driver’s DPC and begins executing the associated DPC routine.
At the same time Processor 2 begins executing the driver’s Unload call
from the system, requesting that all resources be released and that
the driver be unloaded.

Processor 1 then receives an external interrupt which interrupts the
execution
of the DPC routine.

Before releasing the resources, the Unload routine calls KeRemoveQueueDpc
to ensure that all queued DPCs are kept from starting, then releases
all driver resources. However, I don’t believe this call has any affect
on the DPC
whose routine Processor 1 has already started executing. Processor 1
completes
the handling of the external interrupt, then resumes executing the DPC
routine and
attempts to use a resource that has already been released by the Unload
call.

Is there any way to prevent this from happening?

Thanks for any help.
Chris


GET INTERNET ACCESS FROM JUNO!
Juno offers FREE or PREMIUM Internet access for less!
Join Juno today! For your FREE software, visit:
http://dl.www.juno.com/get/web/.


You are currently subscribed to ntdev as: xxxxx@nai.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