阅读:1465回复:4
异步IRP的问题
请问一下,在文件系统过滤驱动中过滤IRP_MJ_READ,然后检查读到的数据,驱动中这样写:
IoCopyCurrentIrpStackLocationToNext( Irp ); IoSetCompletionRoutine( Irp, SfCreateCompletion, &waitEvent, TRUE, TRUE, TRUE ); status = IoCallDriver( devExt->NLExtHeader.AttachedToDeviceObject, Irp ); if (STATUS_PENDING == status) { NTSTATUS localStatus = KeWaitForSingleObject( &waitEvent, Executive, KernelMode, FALSE, NULL ); ASSERT(STATUS_SUCCESS == localStatus); } 如果应用层中是一OVERLAPPED的方式打开的,按照异步操作的理解,ReadFile应该马上就返回的。但是过滤驱动中对READ操作,直到读出数据后才返回,那么是不是由于这个过滤驱动的存在,会造成异步操作失效? |
|
沙发#
发布于:2007-09-26 22:59
You are right, READ IRP can be either synchronous or asynchronous. In kernel, the IRP synchronous flag should be checked to decide whether the IRP should be blocked or pended and queued.
But since there's read ahead logic and lazy writer implemented in IO sub-system. Most of the times, user mode applications won't see differences even FSFD blocks asynchronous IRPs though it's not a correct way which may lead to dead lock potentially. |
|
板凳#
发布于:2007-09-27 19:54
敢问大哥这段话是出自何处,呵呵,我想把这本书找来读读
|
|
地板#
发布于:2007-09-27 22:56
How about from my non-published working journal. :)
If you want to read books, I recommend "NT File System Internals" and "Windows Internals" 4th Edition. |
|
地下室#
发布于:2007-10-03 19:43
使用系统线程可以实现异步操作。
可以参看filedisk源码 |
|