{"id":198,"date":"2010-04-18T00:28:13","date_gmt":"2010-04-18T09:28:13","guid":{"rendered":"\/blog\/?p=198"},"modified":"2023-09-21T09:39:11","modified_gmt":"2023-09-21T00:39:11","slug":"ddk-iostartpacket-keacquirespinlock-%ed%95%a8%ec%88%98-%ec%82%ac%ec%9a%a9%eb%b2%95","status":"publish","type":"post","link":"https:\/\/hasu0707.duckdns.org\/blog\/?p=198","title":{"rendered":"[DDK] IoStartPacket(), KeAcquireSpinLock() \ud568\uc218 \uc0ac\uc6a9\ubc95"},"content":{"rendered":"\n<div class=\"article_post\">\uc55e\uc11c \ub9d0\ud55c \ub3d9\uae30\ud654 \ubb38\uc81c \uc640 StartPacket() \ud568\uc218 \ucc98\ub9ac \ubc29\ubc95\uc744 \uc54c\uc544\ubcf4\uc790,<br \/><br \/>\uc77c\ub2e8 \n\ud568\uc218 \uc774\ub984\uc744 \ubcf4\uba74 \ub514\ubc14\uc774\uc2a4 \ud568\uc218\ub4e4\uc774 \ubb34\uc5c7\uc744 \ud558\ub294\uc9c0 \uc54c \uc218 \uc788\ub2e4.<br \/><br \/>\uac04\ub2e8\ud558\uac8c \uc798\ub77c\uc11c \ubcf4\uba74, Io \ub85c \uc2dc\uc791\ud558\ub294\uac83\uc740 I\/O Manager\uac00 \n\uad00\ub9ac\ud558\ub294 \ud568\uc218\uc774\ub2e4.<br \/><br \/>\uadf8\ub9ac\uace0 Ke \ub294 Kernel Execute \uc774\ub2e4. \uc774\ub807\uac8c \ubcf4\uba74 \ud568\uc218 \uc774\ub984\uc740 \uc5b4\uc808 \uadf8\ub300\ub85c \n\ud574\uc11d\ud558\uba74,<br \/><br \/>\uc815\ud655\ud55c \ub2f5\uc744 \uc5bb\uc744 \uc218 \uc788\ub2e4.<br \/><br \/>\ub3d9\uae30\ud654 \ubb38\uc81c\uac00 \ub514\ubc14\uc774\uc2a4 \ucee4\ub110 \ub2e8\uc5d0\uc11c\ub294 \ub354\uc6b1 \uc2ec\uac01\ud558\ub2e4. \uc5b4\uae38 \uc2dc\uc5d0\ub294 BSOD\ub97c \ubcfc \n\uac83\uc774\ub2e4.<br \/><br \/>\uba40\ud2f0 \ud504\ub85c\uc138\uc11c \uc2dc\uc2a4\ud15c\uc758 \uacbd\uc6b0\uc5d0 DISPATCH_LEVEL\uc758 IRQL\uc5d0\uc11c \uad6c\ub3d9\ub418\ub294 StartIo \ub8e8\ud2f4\uc774<br \/><br \/>2\uac1c\uc758 \n\ud504\ub85c\uc138\uc11c\uc5d0\uc11c \ub3d9\uc2dc\uc5d0 \uc2e4\ud589\ub418\uac8c\ub418\uba74 \ub300\ubd80\ubd84\uc758 \ud558\ub4dc\uc6e8\uc5b4 \ub514\ubc14\uc774\uc2a4\ub294 \uc77c\ub828\uc758<br \/><br \/>\ud3ec\ud2b8\/\ub808\uc9c0\uc2a4\ud130 \uc785\ucd9c\ub825 \uc791\uc5c5\uc2dc \uc7ac\uc9c4\uc785\uc774 \n\ubd88\uac00\ub2a5\ud574\uc9c4\ub2e4.<br \/><br \/>&nbsp;\uc544\ub2c8\uba74, 2\uac1c\uc758 StartIo \ub8e8\ud2f4( Arbitrary Thread\uc5d0\uc11c \ub3d9\uc2dc \uc2e4\ud589 \uc2dc\uac00 \ub420 \uc218 \uc788\uaca0\ub2e4. )\uc774 \ub3d9\uc2dc\uc5d0 \n<br \/><br \/>\uac19\uc740 \uc790\uc6d0\uc758 Context\ub97c \ubcc0\uacbd\ud560 \uc218 \uc788\uac8c \ub41c\ub2e4.<br \/><br \/>&nbsp;\uc774\uc81c IoStartPacket() \uc758 \uc0ac\uc6a9\ubc95\uc744 \ubcf4\uc790. <br \/>\n<h1><br \/>IoStartPacket<\/h1>\n<p>The <b>IoStartPacket<\/b> routine calls the driver's <a class=\"con_link\" href=\"\/\/MS.WDK.v10.6001.071213\/Kernel_r\/hh\/Kernel_r\/DrvrRtns_3227d9e5-10b6-449f-af47-48574e7a00d5.xml.htm\" target=\"_blank\" rel=\"noopener\"><i>StartIo<\/i><\/a> routine with the given IRP or inserts the IRP \ninto the device queue associated with the given device object if the device is \nalready busy.<\/p>\n<p style=\"padding: 2pt 4pt; background: rgb(221, 221, 221) none repeat scroll 0% 0%; font-family: Courier New,Courier,mono; font-style: normal; font-variant: normal; font-weight: normal; font-size: 100%; line-height: normal; font-size-adjust: none; font-stretch: normal; -x-system-font: none; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; cursor: text;\" class=\"syntax\"><b>VOID <\/b><br \/>&nbsp; <b>IoStartPacket(<\/b><br \/><b>&nbsp; &nbsp; IN \nPDEVICE_OBJECT<\/b>&nbsp; <i><a class=\"con_link\" href=\"\" target=\"_blank\" rel=\"noopener\">DeviceObject<\/a><\/i><b>,<\/b><br \/><b>&nbsp; &nbsp; IN PIRP<\/b>&nbsp; \n<i><a class=\"con_link\" href=\"\" target=\"_blank\" rel=\"noopener\">Irp<\/a><\/i><b>,<\/b><br \/><b>&nbsp; &nbsp; IN PULONG<\/b>&nbsp; <i><a class=\"con_link\" href=\"\" target=\"_blank\" rel=\"noopener\">Key<\/a><\/i>&nbsp; \n<b>OPTIONAL,<\/b><br \/><b>&nbsp; &nbsp; IN PDRIVER_CANCEL<\/b>&nbsp; <i><a class=\"con_link\" href=\"\" target=\"_blank\" rel=\"noopener\">CancelFunction<\/a><\/i>&nbsp; \n<b>OPTIONAL<\/b><br \/><b>&nbsp; &nbsp; );<\/b><br \/><\/p>\n<dl><h4>Parameters<\/h4><dt><i>DeviceObject<\/i> \n<\/dt><dd>Pointer to the target device object for the IRP. \n<\/dd><dt><i>Irp<\/i> \n<\/dt><dd>Pointer to the IRP to be processed. \n<\/dd><dt><i>Key<\/i> \n<\/dt><dd>Pointer to a value that determines where to insert the packet into the \ndevice queue. If this is zero, the packet is inserted at the tail of the device \nqueue. \n<\/dd><dt><i>CancelFunction<\/i> \n<\/dt><dd>Specifies the entry point for a driver-supplied Cancel routine. <\/dd><\/dl>\n<h4>Return Value<\/h4>\n<p>None<br \/><br \/>\uadf8\ub807\ub2e4. \uadf8\ub9ac\uace0 \ub3d9\uae30\ud654 \ubb38\uc81c\ub97c \ud574\uacb0\ud558\uae30 \uc704\ud574\uc11c\ub294 Semaphore\uc640 \uac19\uc740 \uc791\uc5c5\uc744 \ud574\uc918\uc57c\ud55c\ub2e4.<br \/><br \/>\uadf8\ub54c \n\uc0ac\uc6a9\ud558\ub294 \ud568\uc218\uac00 KeAcquireSpinLock() \ud568\uc218\uc774\ub2e4. <br \/><br \/><\/p>\n<h1>KeAcquireSpinLock<\/h1>\n<p>The <b>KeAcquireSpinLock<\/b> routine acquires a spin lock so the caller can \nsynchronize access to shared data in a multiprocessor-safe way by raising \nIRQL.<\/p>\n<p style=\"padding: 2pt 4pt; background: rgb(221, 221, 221) none repeat scroll 0% 0%; font-family: Courier New,Courier,mono; font-style: normal; font-variant: normal; font-weight: normal; font-size: 100%; line-height: normal; font-size-adjust: none; font-stretch: normal; -x-system-font: none; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; cursor: text;\" class=\"syntax\"><b>VOID <\/b><br \/>&nbsp; <b>KeAcquireSpinLock(<\/b><br \/><b>&nbsp; &nbsp; IN \nPKSPIN_LOCK<\/b>&nbsp; <i><a class=\"con_link\" href=\"\" target=\"_blank\" rel=\"noopener\">SpinLock<\/a><\/i><b>,<\/b><br \/><b>&nbsp; &nbsp; OUT PKIRQL<\/b>&nbsp; \n<i><a class=\"con_link\" href=\"\" target=\"_blank\" rel=\"noopener\">OldIrql<\/a><\/i><br \/><b>&nbsp; &nbsp; );<\/b><br \/><\/p>\n<dl><h4>Parameters<\/h4><dt><i>SpinLock<\/i> \n<\/dt><dd>Pointer to an initialized spin lock for which the caller provides the \nstorage. \n<\/dd><dt><i>OldIrql<\/i> \n<\/dt><dd>Pointer to a variable that is set to the current IRQL when this call occurs. \n<\/dd><\/dl>\n<h4>Return Value<\/h4>\n<p>None<br \/><br \/>\uadf8\ub9ac\uace0 DISPATCH_LEVEL\uc5d0\uc11c \ub3cc\uace0\uc788\ub294 \uac83\uc774 \ud655\uc2e4\ud55c \ub8e8\ud2f4( StartIo \uac19\uc740 \ub8e8\ud2f4 )\uc774 \uc2e4\ud589\ub420 \n\uacbd\uc6b0\uc5d0\ub294<br \/><br \/>\ub2e4\ub978 \ud568\uc218\ub97c \uc2e4\ud589\ud560 \uc218 \uc788\ub2e4.<br \/><br \/><\/p>\n<h1>KeAcquireSpinLockAtDpcLevel<\/h1>\n<p>The <b>KeAcquireSpinLockAtDpcLevel<\/b> routine acquires a spin lock when the \ncaller is already running at IRQL = DISPATCH_LEVEL.<\/p>\n<p style=\"padding: 2pt 4pt; background: rgb(221, 221, 221) none repeat scroll 0% 0%; font-family: Courier New,Courier,mono; font-style: normal; font-variant: normal; font-weight: normal; font-size: 100%; line-height: normal; font-size-adjust: none; font-stretch: normal; -x-system-font: none; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; cursor: text;\" class=\"syntax\"><b>VOID <\/b><br \/>&nbsp; <b>KeAcquireSpinLockAtDpcLevel(<\/b><br \/><b>&nbsp; &nbsp; IN \nPKSPIN_LOCK<\/b>&nbsp; <i><a class=\"con_link\" href=\"\" target=\"_blank\" rel=\"noopener\">SpinLock<\/a><\/i><br \/><b>&nbsp; &nbsp; );<\/b><br \/><\/p>\n<dl><h4>Parameters<\/h4><dt><i>SpinLock<\/i> \n<\/dt><dd>Pointer to an initialized spin lock for which the caller must provide the \nstorage. <\/dd><\/dl>\n<h4>Return Value<\/h4>\n<p>None<br \/><br \/>\uc774 \ud568\uc218\ub97c \uc2e4\ud589\ud558\uac8c \ub418\uba74, \ub9ac\uc18c\uc2a4\uc758 \ub0ad\ube44\uac00 \uc904\uc5b4\ub4e4\uac8c \ub41c\ub2e4. <br \/><br \/>\uadf8\ub9ac\uace0 \ud568\uc218\uc758 \uc124\uba85\uc744 \uc8fc\uc758\uae4a\uac8c \ubcfc \ud544\uc694\uac00 \n\uc788\ub2e4.<br \/><\/p>\n<h4>Comments<\/h4>\n<p>Drivers call <b>KeAcquireSpinLockAtDpcLevel<\/b> instead of <a class=\"con_link\" href=\"\/\/MS.WDK.v10.6001.071213\/Kernel_r\/hh\/Kernel_r\/k105_387b61b6-b20f-4f17-be47-74c9ed3ac8a1.xml.htm\" target=\"_blank\" rel=\"noopener\"><b>KeAcquireSpinLock<\/b><\/a> for better driver performance if and \nonly if they are already running at IRQL = DISPATCH_LEVEL.<\/p>\n<p>If a driver is running at IRQL &lt;= APC_LEVEL, it should call \n<b>KeAcquireSpinLock<\/b> to have IRQL raised by that routine. \n<b>KeAcquireSpinLockAtDpcLevel<\/b> assumes the caller is already running at IRQL \n= DISPATCH_LEVEL, so no raise is necessary.<\/p>\n<p>The caller should release the spin lock with <a class=\"con_link\" href=\"\/\/MS.WDK.v10.6001.071213\/Kernel_r\/hh\/Kernel_r\/k105_ed15a49d-6903-4f9f-914c-668242701b1e.xml.htm\" target=\"_blank\" rel=\"noopener\"><b>KeReleaseSpinLockFromDpcLevel<\/b><\/a> as quickly as \npossible.<\/p>\n<p>For more information about spin locks, see <mshelp:link tabindex=\"0\" keywords=\"Synchro_213b6c08-7987-4b06-adef-a6ea76702128.xml\"><u><font color=\"#0000ff\">Spin Locks<\/font><\/u><\/mshelp:link>.<br \/><br \/>\uc5ec\uae30\uc11c \uc774 \uad6c\ubb38\uc744 \n\ubcf4\uc790.<br \/><br \/><font color=\"#ff0000\"><strong>for better driver performance if and only \nif they are already running at IRQL = DISPATCH_LEVEL<\/strong><\/font>.<br \/><br \/>\ud655\uc2e4\ud788 \n\uc774\ud574\uac00 \uac00\ub294 \ubd80\ubd84\uc774\ub2e4. \uadf8\ub9ac\uace0 \ub098\uba38\uc9c0 \ub0b4\uc6a9\uc744 \ubcf4\uba74 IRQL\uc774 APC\ub808\ubca8 \ubcf4\ub2e4 \uc791\uc744 \uacbd\uc6b0\uc5d0\ub294 <br \/><br \/>KeAcquireSpinLock()\uc744 \n\uc4f0\ub77c\uace0 \uad8c\uc7a5\ud558\uace0 \uc788\ub2e4. KeAcquireSpinLockAtDpcLevel() \uac19\uc740 \uacbd\uc6b0\uc5d0\ub294<br \/><br \/>DISPATCH_LEVEL\uc5d0\uc11c \uc0ac\uc6a9\ub418\uace0 \n\uc788\ub2e4\uace0 \uac00\uc815\ud558\uace0 \uc788\ub2e4\uace0 \ud55c\ub2e4.<br \/><br \/>\uc0ac\uc6a9\ubc95\uc740 \ub3d9\uc77c\ud558\ub2e4. \uc7a0\uad88\uc8fc\uace0 \ud480\uc5b4\uc8fc\uace0, \ub2e4\uc74c\uc5d0\ub294 \ubcc0\ud654\ub41c \ub514\ubc14\uc774\uc2a4 \ub8e8\ud2f4\uc744 \ud655\uc778\ud574\ubcf4\uc790.<\/p>\n<p>&nbsp;<\/p>\n<p>\ucd9c\ucc98 : <a class=\"con_link\" href=\"http:\/\/ssmhz.tistory.com\/\" target=\"_blank\" rel=\"noopener\">http:\/\/ssmhz.tistory.com\n<\/a><\/p><\/div>\n","protected":false},"excerpt":{"rendered":"<p>\uc55e\uc11c \ub9d0\ud55c \ub3d9\uae30\ud654 \ubb38\uc81c \uc640 StartPacket() \ud568\uc218 \ucc98\ub9ac \ubc29\ubc95\uc744 \uc54c\uc544\ubcf4\uc790, \uc77c\ub2e8 \ud568\uc218 \uc774\ub984\uc744 \ubcf4\uba74 \ub514\ubc14\uc774\uc2a4 \ud568\uc218\ub4e4\uc774 \ubb34\uc5c7\uc744 \ud558\ub294\uc9c0 \uc54c \uc218 \uc788\ub2e4. \uac04\ub2e8\ud558\uac8c \uc798\ub77c\uc11c \ubcf4\uba74, Io \ub85c \uc2dc\uc791\ud558\ub294\uac83\uc740 I\/O Manager\uac00 \uad00\ub9ac\ud558\ub294 \ud568\uc218\uc774\ub2e4. \uadf8\ub9ac\uace0 Ke \ub294 Kernel Execute \uc774\ub2e4. \uc774\ub807\uac8c \ubcf4\uba74 \ud568\uc218 \uc774\ub984\uc740 \uc5b4\uc808 \uadf8\ub300\ub85c \ud574\uc11d\ud558\uba74, \uc815\ud655\ud55c \ub2f5\uc744 \uc5bb\uc744 \uc218 \uc788\ub2e4. \ub3d9\uae30\ud654 \ubb38\uc81c\uac00 \ub514\ubc14\uc774\uc2a4 \ucee4\ub110 \ub2e8\uc5d0\uc11c\ub294 \ub354\uc6b1 [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_import_markdown_pro_load_document_selector":0,"_import_markdown_pro_submit_text_textarea":"","site-sidebar-layout":"default","site-content-layout":"","ast-site-content-layout":"","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"default","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"footnotes":""},"categories":[24],"tags":[],"class_list":["post-198","post","type-post","status-publish","format-standard","hentry","category-development_winddk"],"_links":{"self":[{"href":"https:\/\/hasu0707.duckdns.org\/blog\/index.php?rest_route=\/wp\/v2\/posts\/198","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/hasu0707.duckdns.org\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/hasu0707.duckdns.org\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/hasu0707.duckdns.org\/blog\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/hasu0707.duckdns.org\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=198"}],"version-history":[{"count":0,"href":"https:\/\/hasu0707.duckdns.org\/blog\/index.php?rest_route=\/wp\/v2\/posts\/198\/revisions"}],"wp:attachment":[{"href":"https:\/\/hasu0707.duckdns.org\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=198"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/hasu0707.duckdns.org\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=198"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/hasu0707.duckdns.org\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=198"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}