In the dispatch routine ToasterDispatchPnp() in toaster\func\toaster.c,
when dealing with case IRP_MN_QUERY_STOP_DEVICE, the driver uses following statement to do some synchronization work:
ToasterIoDecrement(fdoData);
KeWaitForSingleObject(
&fdoData->StopEvent,
Executive, // Waiting for reason of a driver
KernelMode, // Waiting in kernel mode
FALSE, // No allert
NULL); // No timeout
and there are also some other similar KeWaitForXXX statements in other case, e.g., IRP_MN_QUERY_REMOVE_DEVICE and IRP_MN_REMOVE_DEVICE.
from the comment in source code, i can tell that the statement is trying to wait for some outstanding IRPs to complete. But what’s the principle in such situation? How can i know when to synchronize, and with whom to synchronize?
above questions may be better expressed as follow:
can i say that toaster’s dispatch routines may be classified into 4 categories, and dispatch routines for IRP_MJ_CREATE, IRP_MJ_CLOSE, IRP_MJ_READ and IRP_MJ_WRITE are called by I/O mgr, dispatch routine for IRP_MJ_PNP is called by PnP mgr, and dispatch routine IRP_MJ_POWER is called by Power mgr, and dispatch routine for IRP_MJ_SYSTEM_CONTROL is called by WMI ? and can i say that those 4 categories of dispatch routines may be called in parallel (i.e., several dispatch routines may be executing overlappedly)?
and can i say that i should synchronize among them?
DDK just tell me what to do, but never tell me why. some internel information on how I/O mgr and PnP mgr is going will be great help for me.
any article or hyperlink on this is also appreciated.
thanks in advance for clarifying it.
WeiYu, Dong
DO YOU YAHOO!?
ÑÅ»¢ÓÊÏ䳬ǿÔöÖµ·þÎñ£2G³¬´ó¿Õ¼ä¡¢pop3ÊÕÐÅ¡¢ÎÞÏÞÁ¿ÓʼþÌáÐÑ