The sample ‘toaster’ driver that comes with the win2k ddk has some strange
locking going on.
Both the bus and toaster drivers keep has a counter ‘OutstandingIO’ that is
initalized to 1, and two events, StopEvent and RemoveEvent.
StopEvent is set whenever OutstandingIO <= 1 (thus it is initalized in the
“signaled” state). It is waited on for an IRP_MN_QUERY_STOP_DEVICE.
RemoveEvent is set whenever OutstandingIO == 0. It is waited on for
IRP_MN_QUERY_REMOVE_DEVICE.
While the code makes it sufficiently clear that this is what happens, I don’t
see the reason *why* there are two locks – if the device can be stopped for
resource balancing, why can’t it be removed? It would be very much as if the
device was stopped and never restarted (it seems that this may happen due to a
lack of resources?).
The sample serial driver that is provided does not seem to have this behavior –
but then, the fact that it has actual code (unlike the virtual ‘toaster’ driver)
may be hiding it.
Could someone please shed some light on this locking stuff?
–
- Stevie-O
“Intuitive” mostly means “what the writer or speaker of intuitive likes”.
– Bruce Ediger