Hi
In C:\WinDDK\7600.16385.1\src\general\cancel\startio example, there is a comment about device’s state:
// Try inserting the IRP in the queue. If the device is busy, // the IRP will get queued and the following function will // return SUCCESS. If the device is not busy, it will set the // IRP to DeviceExtension->CurrentIrp and return UNSUCCESSFUL. // if (!NT_SUCCESS(IoCsqInsertIrpEx(&devExtension->CancelSafeQueue, Irp, NULL, NULL))) { IoMarkIrpPending(Irp);CsampInitiateIo(DeviceObject); } else { // // Do not touch the IRP once it has been queued because another thread // could remove the IRP and complete it before this one gets to run. // // DO_NOTHING(); }
My question is:
Why did they write “If the device is busy, the IRP will get queued”?
Does IoCsqInsertIrpEx checks device’s state for me?
Think about it. The io csq has now way of checking device state…there is no std place where state is kept for it to check. What the doc is saying that the csq state represents the hw state. If the queue is busy, that means there is a request already being processed and thus the hw is busy.
d
dent from a phine with no keynoard
-----Original Message-----
From: xxxxx@gmail.com
Sent: Thursday, February 10, 2011 7:54 AM
To: Windows System Software Devs Interest List
Subject: [ntdev] IoCsqInsertIrpEx and Device Busy State
Hi
In C:\WinDDK\7600.16385.1\src\general\cancel\startio example, there is a comment about device’s state:
// Try inserting the IRP in the queue. If the device is busy, // the IRP will get queued and the following function will // return SUCCESS. If the device is not busy, it will set the // IRP to DeviceExtension->CurrentIrp and return UNSUCCESSFUL. // if (!NT_SUCCESS(IoCsqInsertIrpEx(&devExtension->CancelSafeQueue, Irp, NULL, NULL))) { IoMarkIrpPending(Irp);CsampInitiateIo(DeviceObject); } else { // // Do not touch the IRP once it has been queued because another thread // could remove the IRP and complete it before this one gets to run. // // DO_NOTHING(); }
My question is:
Why did they write “If the device is busy, the IRP will get queued”?
Does IoCsqInsertIrpEx checks device’s state for me?
NTDEV is sponsored by OSR
For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars
To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer
Hmm…
If i understand right, “If the queue is busy” means: if there is already an irp in the queue, it means we can’t start startio because device must be busy. That’s all. Is that right? Can you please confirm that?
I have one more question about usb driver and device state.
We don’t check Device busy/ready state while developing driver for usb. We check its pnp state but not queue state because we forward our irp lower device.
If that’s correct. Can we say, if we forward irp to next driver, checking device pnp state is enough to forward irp and we are done, but if our driver makes actual device operation so we must check both pnp state and queue state. Can we say that as a rule?