Handling PnP Paging Request

  1. The following explains why the DO_POWER_PAGABLE bit must be set on the way down and not on the way up:

    The power requirements state that if any lower device object sets the DO_POWER_PAGABLE bit, all higher-level drivers must do the same. If the filter driver fails to set the DO_POWER_PAGABLE bit prior to sending the paging request IRP down the stack, it could violate this condition as follows:

    Suppose the filter driver does not set the DO_POWER_PAGABLE bit in its Filter DO before forwarding the paging request IRP to the drivers beneath it in the driver stack. Next suppose that a lower driver sets the DO_POWER_PAGABLE bit in its own DO. Finally, suppose that prior to the completion of the IRP by the filter driver a power IRP occurs. At that point, the DO_POWER_PAGABLE bit would be cleared in the Filter DO but would be set in the DO of the lower-level driver, causing a system crash.

    It is safe to set the DO_POWER_PAGABLE bit before forwarding a paging request down the stack, because there is no longer an active paging file on the filter driver's device, and therefore no more paging I/O will occur on it. If the request to remove this paging file succeeds, the filter driver will be done. If the request fails, the filter driver can restore the original state of its flags by simply clearing the DO_POWER_PAGABLE bit prior to completing the IRP. Because the paging file requests are serialized, there is no danger that some other thread will have modified this bit since the filter driver last altered it.

    译文为:
            电源管理的需求规定了如果一个更低层的设备对象设置了 DO_POWER_PAGABLE 位,那么所有的更高 层驱动也必须这么做。如果过滤驱动没有在下发分页的 IRP 之前设置 DO_POWER_PAGABLE 位,它可能 违反下面的这些条件:
            假设过滤驱动没有在下发分页 IRP 之前设置 DO_POWER_PAGABLE 位, 再假设下层驱动设置了自己 的设备对象的 DO_POWER_PAGABLE 位。最后,假设在这个过滤驱动的 IRP 完成之前,一个电源 IRP 发 生了。这个时候,DO_POWER_PAGABLE 位将被该过滤驱动清除,但它又被更低层的驱动设置了,就引起 了一个系统崩溃。
           在一个分页请求下发之前设置 DO_POWER_PAGABLE 位是安全的,因为这里不再有一个活跃的分页文 件在这个过滤驱动的设备上,因此也不会有分页 I/O 在上面发生。如果移除这个页面文件的请求成功 执行,过滤驱动将会去做,如果请求失败,过滤驱动能够恢复它的标志的原始状态,只需要在完成这个  IRP 之前简单地清除一下 DO_POWER_PAGABLE 位即可。因为页面文件请求是序列化的。即使其它线程在 过滤驱动最后改变它之后又修改了这个位,这也是没有危险的。

    原文链接: http://msdn.microsoft.com/zh-cn/ff554992
  • 7
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 4
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值