WDF 驱动 pending 操作

本文深入探讨了在KMDF驱动中处理读写请求的方法,包括请求的前向传递和待处理请求队列的管理。通过具体代码示例展示了如何正确地将无法立即满足的请求前向传递到待处理队列,并在完成写操作后重新调度这些请求。讨论了当前实现的优缺点,旨在确保请求处理的高效性和可靠性。

    wdf 似乎没有 IoMarkIrpPending ,不过好像可以用 WdfRequestForwardToIoQueue 代替。

Newbie question about correct handling for pendingrequests


Hi again!

 

After digging through all the documentation and a fewsamples I'm still not sure

if my queue/request handling is correct or

maybe has a flaw that will show up sooner or later...

 

In my KMDF driver I currently have one (sequential) queuefor read and write

requests and one manual

queue for pending read requests. (Writes will alwayssucceed!)

All synchronization and execution levels are left attheir default values.

 

Now my question:

 

In my read event handler I simply forward the request (ifI cannot fulfill it

immediately) like this:

 

status = WdfRequestForwardToIoQueue(Request,pDevContext->PendingReadQueue);

 

In my write handler - after having written to my memoryI'm looping over the

pending request queue like this:

 

    // Check forpending reads... and move them to main queue

    do

    {

        WDFREQUESTrequest;

 

        status =WdfIoQueueRetrieveNextRequest(pDevContext->PendingReadQueue,

&request);

 

        // Found anentry?

        if(NT_SUCCESS(status))

        {

            status= WdfRequestForwardToIoQueue(request,

pDevContext->ReadQueue);

            if(!NT_SUCCESS(status))

            {

               WdfRequestCompleteWithInformation(request, STATUS_UNSUCCESSFUL,

0);

               return;

            }

        }

    }

    while(NT_SUCCESS(status));

 

Now my question: Although this works fine so far I'd liketo ensure that this is

a correct approach or if

someone sees future problems with this code?

 


评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值