<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.msdn.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Windows Driver Kit (WDK) Documentation Blog : I/O cancellation kernel</title><link>http://blogs.msdn.com/wdkdocs/archive/tags/I_2F00_O+cancellation+kernel/default.aspx</link><description>Tags: I/O cancellation kernel</description><dc:language>en-US</dc:language><generator>CommunityServer 2.1 SP1 (Build: 61025.2)</generator><item><title>Yes, No, Okay, Cancel!: I/O Cancellation in Windows</title><link>http://blogs.msdn.com/wdkdocs/archive/2008/06/30/yes-no-okay-cancel-i-o-cancellation-in-windows.aspx</link><pubDate>Mon, 30 Jun 2008 17:51:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8671578</guid><dc:creator>wdkblog</dc:creator><slash:comments>2</slash:comments><comments>http://blogs.msdn.com/wdkdocs/comments/8671578.aspx</comments><wfw:commentRss>http://blogs.msdn.com/wdkdocs/commentrss.aspx?PostID=8671578</wfw:commentRss><description>&lt;P class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;One of the leading causes of crashes for Microsoft Windows can be traced to device drivers that do not handle cancel requests properly, or at all. Cancellation is one of the most difficult concepts in driver technology to get right, and this blog entry will help clear up some of the confusion over cancellation.&lt;?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;H1 style="MARGIN: 24pt 0in 0pt"&gt;&lt;FONT size=5&gt;&lt;FONT color=#365f91&gt;&lt;FONT face=Cambria&gt;What is Cancellation?&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/H1&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;Device drivers sit between a user-mode software application and a hardware device. Sometimes the "device" can be software, such as named pipes or TCP/IP, and other times there may not be a user-mode application in the loop. The application sends data to the device, the device sends data back, and the driver sits in the middle, passing data back and forth. When the data transfers are done, the hardware signals the driver via an interrupt routine, the driver cleans up all I/O requests, and the close routine finishes up the job.&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;However, in a not-so-ideal universe, the data may not reach the user of the application quickly enough or the user may decide they don’t need the data after all, in which case the user decides to kill the application and then the system hangs. In many cases, the actual problem is that the driver doesn't handle the cancellation request properly, the hardware is malfunctioning, or something else has gone wrong … and the system hangs.&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;This is really all about IRPs, those hard-working I/O Request Packets that carry information around the system. When an I/O request is cancelled by an application or another driver, you must process that IRP. This sounds easy, but when your driver is part of a stack of drivers and you depend on hardware that may fail, or there are other things going on that slow down the IRP delivery, you need to think about all options. And cancellation requests are particularly difficult because there are several ways to handle cancellation.&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;H1 style="MARGIN: 24pt 0in 0pt"&gt;&lt;FONT size=5&gt;&lt;FONT color=#365f91&gt;&lt;FONT face=Cambria&gt;Cancellation Options&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/H1&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;There are a few different ways to think about cancellation. Since everything depends on what kind of application and what kind of hardware you are working with, the choice may not be simple. &lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;OL style="MARGIN-TOP: 0in" type=1&gt;
&lt;LI class=MsoNormal style="MARGIN: 0in 0in 10pt; mso-list: l1 level1 lfo5; tab-stops: list .5in"&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;You can wait for a cancellation request to come in and try to figure out what to do. You have two basic choices at that point:&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/LI&gt;&lt;/OL&gt;
&lt;P class=ListParagraphCxSpFirst style="MARGIN: 0in 0in 0pt 1in; TEXT-INDENT: -0.25in; mso-list: l3 level2 lfo1; mso-add-space: auto"&gt;&lt;SPAN style="mso-fareast-font-family: Calibri; mso-bidi-font-family: Calibri"&gt;&lt;SPAN style="mso-list: Ignore"&gt;&lt;FONT face=Calibri size=3&gt;a.&lt;/FONT&gt;&lt;SPAN style="FONT: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;Cut your losses and run. Just tell the hardware to stop, throw out the data, or whatever, and let the system shut the application and the communication to the device.&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=ListParagraphCxSpMiddle style="MARGIN: 0in 0in 0pt 1in; TEXT-INDENT: -0.25in; mso-list: l3 level2 lfo1; mso-add-space: auto"&gt;&lt;SPAN style="mso-fareast-font-family: Calibri; mso-bidi-font-family: Calibri"&gt;&lt;SPAN style="mso-list: Ignore"&gt;&lt;FONT face=Calibri size=3&gt;b.&lt;/FONT&gt;&lt;SPAN style="FONT: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;Complete the operation if it is far enough along that it doesn’t need to wait anyway. If you are operating heavy machinery, you don't want to stop in the middle.&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=ListParagraphCxSpMiddle style="MARGIN: 0in 0in 0pt 0.75in; mso-add-space: auto"&gt;&lt;o:p&gt;&lt;FONT face=Calibri size=3&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/P&gt;
&lt;P class=ListParagraphCxSpMiddle style="MARGIN: 0in 0in 0pt 0.5in; TEXT-INDENT: -0.25in; mso-list: l3 level1 lfo1"&gt;&lt;SPAN style="mso-fareast-font-family: Calibri; mso-bidi-font-family: Calibri"&gt;&lt;SPAN style="mso-list: Ignore"&gt;&lt;FONT face=Calibri size=3&gt;2.&lt;/FONT&gt;&lt;SPAN style="FONT: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;See if your I/O requests are taking too long. In the past there weren’t any guidelines on how long a request should take. Paradoxically, as computers get faster, we ask them to do more, so how long a request takes may not be clear. If your driver proactively checks to see how long the requests are taking, you might discover important problems in the hardware, software, or your understanding of what the user will put up with. (People are more impatient now than they were five years ago!)&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=ListParagraphCxSpMiddle style="MARGIN: 0in 0in 0pt 1in; TEXT-INDENT: -0.25in; mso-list: l3 level2 lfo1; mso-add-space: auto"&gt;&lt;SPAN style="mso-fareast-font-family: Calibri; mso-bidi-font-family: Calibri"&gt;&lt;SPAN style="mso-list: Ignore"&gt;&lt;FONT face=Calibri size=3&gt;a.&lt;/FONT&gt;&lt;SPAN style="FONT: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;One possibility is to set up a watchdog on the hardware to check after 30 seconds have elapsed. You might think of this as a warning and to perform further checks to see if the hardware is still plugged in, the network is slow, or whatever. The point of view of a device driver is limited to what it is told but you can look for more information if something might be going wrong.&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=ListParagraphCxSpMiddle style="MARGIN: 0in 0in 0pt 1in; TEXT-INDENT: -0.25in; mso-list: l3 level2 lfo1; mso-add-space: auto"&gt;&lt;SPAN style="mso-fareast-font-family: Calibri; mso-bidi-font-family: Calibri"&gt;&lt;SPAN style="mso-list: Ignore"&gt;&lt;FONT face=Calibri size=3&gt;b.&lt;/FONT&gt;&lt;SPAN style="FONT: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;Another possibility is to decide after 5 minutes that something definitely isn’t working and shut things down. Most users won’t wait that long, but 5 minutes is a good drop-dead time.&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=ListParagraphCxSpLast style="MARGIN: 0in 0in 10pt 0.5in; TEXT-INDENT: -0.25in; mso-list: l3 level1 lfo1"&gt;&lt;SPAN style="mso-fareast-font-family: Calibri; mso-bidi-font-family: Calibri"&gt;&lt;SPAN style="mso-list: Ignore"&gt;&lt;FONT face=Calibri size=3&gt;3.&lt;/FONT&gt;&lt;SPAN style="FONT: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;Do nothing. Not recommended. Apparently not everyone implements a Cancel routine in their driver. Microsoft doesn’t require it. Maybe your hardware is fast and never fails and you’ve got a secret deal with the scheduler. But you might want to think about it. The world is getting more complicated and that definitely applies to hardware and software.&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;H1 style="MARGIN: 24pt 0in 0pt"&gt;&lt;FONT size=5&gt;&lt;FONT color=#365f91&gt;&lt;FONT face=Cambria&gt;Where’s My IRP, Dude?&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/H1&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;Under some circumstances, the operating system or another driver may cancel the IRP your cancel routine registered. This can be a problem.&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;For example, in the Windows Driver Kit (WDK) Kernel-Mode Driver&amp;nbsp;Architecture “&lt;A class="" href="http://msdn.microsoft.com/en-us/library/ms796186.aspx" mce_href="http://msdn.microsoft.com/en-us/library/ms796186.aspx"&gt;Registering a Cancel Routine&lt;/A&gt;” topic,&amp;nbsp;we tell you:&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 6pt 8.4pt; VERTICAL-ALIGN: top; LINE-HEIGHT: 140%"&gt;&lt;SPAN style="FONT-SIZE: 8.5pt; LINE-HEIGHT: 140%; FONT-FAMILY: Verdana"&gt;If a driver does not have a &lt;I&gt;StartIo &lt;/I&gt;routine, its dispatch routines must do the following before queuing an IRP for further processing by other driver routines:&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 1.8pt 34.8pt; VERTICAL-ALIGN: top; TEXT-INDENT: -0.25in; LINE-HEIGHT: 140%; mso-list: l2 level1 lfo2; tab-stops: list 44.4pt; mso-margin-top-alt: auto"&gt;&lt;SPAN style="FONT-SIZE: 8.5pt; LINE-HEIGHT: 140%; FONT-FAMILY: Verdana; mso-fareast-font-family: Verdana; mso-bidi-font-family: Verdana"&gt;&lt;SPAN style="mso-list: Ignore"&gt;1.&lt;SPAN style="FONT: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 8.5pt; LINE-HEIGHT: 140%; FONT-FAMILY: Verdana"&gt;Call &lt;/SPAN&gt;&lt;A href="http://msdn.microsoft.com/en-us/library/ms801500.aspx"&gt;&lt;B&gt;&lt;SPAN style="FONT-SIZE: 8.5pt; LINE-HEIGHT: 140%; FONT-FAMILY: Verdana; mso-bidi-font-size: 11.0pt"&gt;IoAcquireCancelSpinLock&lt;/SPAN&gt;&lt;/B&gt;&lt;/A&gt;&lt;SPAN style="FONT-SIZE: 8.5pt; LINE-HEIGHT: 140%; FONT-FAMILY: Verdana"&gt;. &lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 1.8pt 34.8pt; VERTICAL-ALIGN: top; TEXT-INDENT: -0.25in; LINE-HEIGHT: 140%; mso-list: l2 level1 lfo2; tab-stops: list 44.4pt; mso-margin-top-alt: auto"&gt;&lt;SPAN style="FONT-SIZE: 8.5pt; LINE-HEIGHT: 140%; FONT-FAMILY: Verdana; mso-fareast-font-family: Verdana; mso-bidi-font-family: Verdana"&gt;&lt;SPAN style="mso-list: Ignore"&gt;2.&lt;SPAN style="FONT: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 8.5pt; LINE-HEIGHT: 140%; FONT-FAMILY: Verdana"&gt;Call &lt;/SPAN&gt;&lt;A href="http://msdn.microsoft.com/en-us/library/ms801183.aspx"&gt;&lt;B&gt;&lt;SPAN style="FONT-SIZE: 8.5pt; LINE-HEIGHT: 140%; FONT-FAMILY: Verdana; mso-bidi-font-size: 11.0pt"&gt;IoSetCancelRoutine&lt;/SPAN&gt;&lt;/B&gt;&lt;/A&gt;&lt;SPAN style="FONT-SIZE: 8.5pt; LINE-HEIGHT: 140%; FONT-FAMILY: Verdana"&gt; with the input IRP and the entry point for a driver-supplied &lt;I&gt;Cancel &lt;/I&gt;routine. &lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 10pt 34.8pt; VERTICAL-ALIGN: top; TEXT-INDENT: -0.25in; LINE-HEIGHT: 140%; mso-list: l2 level1 lfo2; tab-stops: list 44.4pt; mso-margin-top-alt: auto"&gt;&lt;SPAN style="FONT-SIZE: 8.5pt; LINE-HEIGHT: 140%; FONT-FAMILY: Verdana; mso-fareast-font-family: Verdana; mso-bidi-font-family: Verdana"&gt;&lt;SPAN style="mso-list: Ignore"&gt;3.&lt;SPAN style="FONT: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 8.5pt; LINE-HEIGHT: 140%; FONT-FAMILY: Verdana"&gt;Call &lt;/SPAN&gt;&lt;A href="http://msdn.microsoft.com/en-us/library/aa490874.aspx"&gt;&lt;B&gt;&lt;SPAN style="FONT-SIZE: 8.5pt; LINE-HEIGHT: 140%; FONT-FAMILY: Verdana; mso-bidi-font-size: 11.0pt"&gt;IoReleaseCancelSpinLock&lt;/SPAN&gt;&lt;/B&gt;&lt;/A&gt;&lt;SPAN style="FONT-SIZE: 8.5pt; LINE-HEIGHT: 140%; FONT-FAMILY: Verdana"&gt;. &lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;This list sounds good, but if the IRP was already cancelled before the driver routine, you have a problem. There are various ways that an IRP can be cancelled before it gets to you; some of them are very subtle&lt;SPAN style="FONT-SIZE: 11pt; LINE-HEIGHT: 115%; FONT-FAMILY: Calibri; mso-fareast-font-family: 'Times New Roman'; mso-ansi-language: EN-US; mso-fareast-language: EN-US; mso-bidi-language: AR-SA; mso-bidi-font-family: 'Times New Roman'"&gt;, and we will be covering them in future&amp;nbsp;documentation&lt;/SPAN&gt;.&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;H1 style="MARGIN: 24pt 0in 0pt"&gt;&lt;FONT size=5&gt;&lt;FONT color=#365f91&gt;&lt;FONT face=Cambria&gt;What Can I Do About This?&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/H1&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;Microsoft is working on two things in the near future:&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=ListParagraphCxSpFirst style="MARGIN: 0in 0in 0pt 0.5in; TEXT-INDENT: -0.25in; mso-list: l0 level1 lfo3"&gt;&lt;SPAN style="mso-fareast-font-family: Calibri; mso-bidi-font-family: Calibri"&gt;&lt;SPAN style="mso-list: Ignore"&gt;&lt;FONT face=Calibri size=3&gt;1.&lt;/FONT&gt;&lt;SPAN style="FONT: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;The documentation covering I/O Cancellation will be revised and we’ll tell you when it is fixed.&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=ListParagraphCxSpLast style="MARGIN: 0in 0in 10pt 0.5in; TEXT-INDENT: -0.25in; mso-list: l0 level1 lfo3"&gt;&lt;SPAN style="mso-fareast-font-family: Calibri; mso-bidi-font-family: Calibri"&gt;&lt;SPAN style="mso-list: Ignore"&gt;&lt;FONT face=Calibri size=3&gt;2.&lt;/FONT&gt;&lt;SPAN style="FONT: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;We’ll provide a set of guidelines for cancellation so that your driver can be a good citizen in the increasingly crowded world of Windows. &lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;But there are two major guidelines in place that you may or may not know about now.&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;H2 style="MARGIN: 10pt 0in 0pt"&gt;&lt;FONT size=4&gt;&lt;FONT color=#4f81bd&gt;&lt;FONT face=Cambria&gt;Guideline 1:&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;Use the Windows Driver Foundation&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/H2&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;&lt;FONT face=Calibri size=3&gt;If your hardware and software can fit the requirements, the Windows Driver Foundation can do a lot of the housekeeping, not only for I/O cancellation, but also for other difficult operations such as power management and Plug-and-Play. For more information about the Windows Driver Foundation, get started on &lt;/FONT&gt;&lt;A href="http://go.microsoft.com/fwlink/?LinkID=53698&amp;amp;clcid=0x409"&gt;&lt;FONT face="Times New Roman" size=3&gt;WHDC&lt;/FONT&gt;&lt;/A&gt;&lt;FONT face=Calibri size=3&gt; and then dive into the WDK section on “&lt;/FONT&gt;&lt;A href="http://go.microsoft.com/fwlink/?LinkID=122104&amp;amp;clcid=0x409"&gt;&lt;FONT face="Times New Roman" size=3&gt;Windows Driver Foundation&lt;/FONT&gt;&lt;/A&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;.” &lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;H2 style="MARGIN: 10pt 0in 0pt"&gt;&lt;FONT size=4&gt;&lt;FONT color=#4f81bd&gt;&lt;FONT face=Cambria&gt;Guideline 2: Use Cancel-Safe Queues&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/H2&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;Windows Vista has added a new technology called Cancel-Safe Queues. Cancel-safe IRP queues split IRP handling into two parts:&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;OL style="MARGIN-TOP: 0in" type=1&gt;
&lt;LI class=MsoNormal style="MARGIN: 0in 0in 10pt; mso-list: l4 level1 lfo4; tab-stops: list .5in"&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;The driver provides a set of callback routines that implement standard operations on the driver's IRP queue. The provided operations include inserting and removing IRPs from the queue, and locking and unlocking the queue. &lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/LI&gt;
&lt;LI class=MsoNormal style="MARGIN: 0in 0in 10pt; mso-list: l4 level1 lfo4; tab-stops: list .5in"&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;Whenever the driver needs to actually insert or remove an IRP from the queue, it uses the system-provided &lt;B&gt;IoCsq&lt;/B&gt;&lt;I&gt;Xxx&lt;/I&gt; routines along with its callback routines (?). The system-provided routines handle all synchronization and IRP canceling logic for the driver. &lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/LI&gt;&lt;/OL&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;&lt;FONT face=Calibri size=3&gt;Drivers that use cancel-safe IRP queues do not implement &lt;I&gt;Cancel&lt;/I&gt; routines to support IRP cancellation. For more information about Cancel-Safe Queues, see the “&lt;/FONT&gt;&lt;A href="http://go.microsoft.com/fwlink/?LinkID=122105&amp;amp;clcid=0x409"&gt;&lt;FONT face="Times New Roman" size=3&gt;Cancel-Safe IRP Queues&lt;/FONT&gt;&lt;/A&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;” topic in the WDK Kernel-Mode Driver&amp;nbsp;Architecture section.&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;H1 style="MARGIN: 24pt 0in 0pt"&gt;&lt;FONT size=5&gt;&lt;FONT color=#365f91&gt;&lt;FONT face=Cambria&gt;For More Information&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/H1&gt;
&lt;UL&gt;
&lt;LI&gt;
&lt;DIV class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;&lt;FONT face=Calibri size=3&gt;Mark Russinovich has an &lt;/FONT&gt;&lt;A href="http://go.microsoft.com/fwlink/?LinkID=122106&amp;amp;clcid=0x409"&gt;&lt;FONT face="Times New Roman" size=3&gt;article on I/O Completion and Cancellation for Windows Vista&lt;/FONT&gt;&lt;/A&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;.&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/DIV&gt;&lt;/LI&gt;
&lt;LI&gt;
&lt;DIV class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;&lt;FONT face=Calibri size=3&gt;You can read an excellent &lt;/FONT&gt;&lt;A href="http://go.microsoft.com/fwlink/?LinkID=122107&amp;amp;clcid=0x409"&gt;&lt;FONT face="Times New Roman" size=3&gt;whitepaper on I/O Cancellation&lt;/FONT&gt;&lt;/A&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;.&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/DIV&gt;&lt;/LI&gt;
&lt;LI&gt;
&lt;DIV class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;&lt;FONT face=Calibri size=3&gt;Three Microsoft members of the I/O Cancellation team talk on a &lt;/FONT&gt;&lt;A href="http://go.microsoft.com/fwlink/?LinkID=122108&amp;amp;clcid=0x409"&gt;&lt;FONT face="Times New Roman" size=3&gt;Channel 9 video&lt;/FONT&gt;&lt;/A&gt;.&lt;o:p&gt;&lt;/o:p&gt;&lt;/DIV&gt;&lt;/LI&gt;&lt;/UL&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;&lt;FONT face=Calibri size=3&gt;Stay tuned for more about I/O Cancellation!&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;&lt;o:p&gt;&lt;FONT face=Calibri size=3&gt;Seth McEvoy [MSFT], WDK Technical Writer&lt;BR&gt;&lt;A href="http://blogs.msdn.com/wdkdocs"&gt;http://blogs.msdn.com/wdkdocs&lt;/A&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;BR&gt;This posting is provided "AS IS" with no warranties, and confers no rights.&lt;/FONT&gt;&lt;/o:p&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;&lt;SPAN style="FONT-SIZE: 11pt; LINE-HEIGHT: 115%; FONT-FAMILY: Calibri; mso-fareast-font-family: 'Times New Roman'; mso-ansi-language: EN-US; mso-fareast-language: EN-US; mso-bidi-language: AR-SA; mso-bidi-font-family: 'Times New Roman'"&gt;Seth McEvoy is the kernel programmer writer for the Windows Driver Kit. He has worked on several operating systems at Microsoft and considers operating systems his favorite hobby.&lt;/SPAN&gt;&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=8671578" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/wdkdocs/archive/tags/I_2F00_O+cancellation+kernel/default.aspx">I/O cancellation kernel</category></item></channel></rss>