Path: news.mitre.org!blanket.mitre.org!philabs!newsjunkie.ans.net!newsfeeds.ans.net!news-was.dfn.de!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!howland.erols.net!usc!newshub.cts.com!newsfeed.cts.com!cmkrnl!jeh From: jeh@cmkrnl.com (Jamie Hanrahan) Newsgroups: comp.os.ms-windows.programmer.nt.kernel-mode Subject: Re: Can completion routines call IoCallDriver()? Message-ID: <1998Jan12.115639.8397@cmkrnl> Date: 12 Jan 98 11:56:39 PST References: <01bd1e5d$6fc11ac0$0101012a@burning> Organization: Kernel Mode Systems, San Diego, CA Lines: 58 In article <01bd1e5d$6fc11ac0$0101012a@burning>, "Rich Testardi" writes: > Hi, > > If you believe the DDK (and I do)... > > In a device filter driver, completion routines are called > at IRQL <= DISPATCH_LEVEL [see DDK, Kernel-Mode Drivers, > Design Guide, Ch 13.1], and dispatch routines are/may be > called at IRQL <= APC_LEVEL (for read/write) or at IRQL > == PASSIVE LEVEL (for all others) [see DDK, Kernel-Mode > Drivers, Design Guide, Ch 6.1]... > > DOES THIS MEAN THAT A COMPLETION ROUTINE MAY NOT CALL A > LOWER LEVEL DRIVER'S DISPATCH ROUTINE VIA IoCallDriver()? No. Your interpretation of DG 6.1 is a little overzealous. It says "MOST dispatch routines are called [...] at PASSIVE_LEVEL, with the following exceptions", and for exceptions it mentions APC_LEVEL. However this does not exclude the possibility of dispatch routines being called at DISPATCH_LEVEL. Note the comments in the third bullet item in section 7.2.4. Yes, calling IoCallDriver from DISPATCH_LEVEL results in all lower-layer drivers' Dispatch routines running at DISPATCH_LEVEL, and this means that not all lower-layer drivers will surivive, but it isn't illegal. Nobody ever said that the upper layer didn't have to know some things about the lower layer and conform with the latter's requirements. > I see lots of people both sleeping in dispatch routines > (which I am inclined to believe is OK, but not very cool), Right. > and lots of people calling dispatch routines from completion > routines (which I am inclined to believe is NOT OK)... > Just look at the DDK samples for the full range of work -- > diskperf.c does BOTH... > > How does this work??? It works because in this particular case, the lower layer is ok with being called from DISPATCH_LEVEL. > If it doesn't work, how does a simple filter driver > work that wants to retry failed I/O's? (Yes, I can use > a worker thread...) You've answered your own question. Note that if retries are not common, this isn't a big concern re. performance. --- Jamie Hanrahan, Kernel Mode Systems, San Diego CA Internet: jeh@cmkrnl.com (JH645) CompuServe: 74140,2055 drivers, internals, networks, applications, and training for VMS and Windows NT NT driver FAQ, links, and other information: http://www.cmkrnl.com/ If you post a reply in news, please don't e-mail it too.