How can a user mode thread request synchronous / asynchronous mode for
an I/O operation? How a driver will come to know what mode of I/O is
expected for a request? Should driver provide different code paths to
handle these requests?
–Sachin
How can a user mode thread request synchronous / asynchronous mode for
an I/O operation? How a driver will come to know what mode of I/O is
expected for a request? Should driver provide different code paths to
handle these requests?
–Sachin
The user requests sync versus asynch by use of the OVERLAPPED structure and
the FILE_FLAG_OVERLAPPED flag on CreateFile. All driver paths should be
coded asynchronous (i.e. if they take a long time, queue the request and
return status pending). The I/O manager takes care pending a synchronous
request for the user, and making it an ansyc request for the driver.
–
Don Burn (MVP, Windows DDK)
Windows 2k/XP/2k3 Filesystem and Driver Consulting
“Sachin” wrote in message news:xxxxx@ntdev…
> How can a user mode thread request synchronous / asynchronous mode for
> an I/O operation? How a driver will come to know what mode of I/O is
> expected for a request? Should driver provide different code paths to
> handle these requests?
>
> --Sachin
>
The driver doesn’t know, nor should it really care whether the client is
performing asynchronous or synchronous I/O.
For short operations - those that don’t wait on hardware or block for
long periods of time, you can just complete them in the dispatch routine
and not worry about. For longer running operations, you mark the IRP as
pending and return STATUS_PENDING from your dispatch routine - the NTIO
manager will either return control to the client (asynch) or block until
the I/O completes (synch).
NTIO can’t make a synchronous operation look asynchronous to the client
-p
-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Sachin
Sent: Thursday, August 19, 2004 5:31 AM
To: Windows System Software Devs Interest List
Subject: [ntdev] Synchronous Vs Asynchronous I/O
How can a user mode thread request synchronous / asynchronous mode for
an I/O operation? How a driver will come to know what mode of I/O is
expected for a request? Should driver provide different code paths to
handle these requests?
–Sachin
Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256
You are currently subscribed to ntdev as: xxxxx@windows.microsoft.com
To unsubscribe send a blank email to xxxxx@lists.osr.com
> How can a user mode thread request synchronous / asynchronous mode for
an I/O operation?
It depends on file object type, which in turn depends on whether
FILE_FLAG_OVERLAPPED was specified in CreateFile.
How a driver will come to know what mode of I/O is
expected for a request?
if( FileObject->Flags | FO_SYNCHRONOUS_IO )
There is also IoIsOperationSynchronous routine.
Should driver provide different code paths to
handle these requests?
Not needed at all, unless you grab some mutex-like locks in request handling.
If you do so - then with a non-synchronous file object it can be a good idea
to:
a) use TryToAcquire instead of Acquire
b) if TryToAcquire fails - return STATUS_PENDING while offloading the IRP to
the work item
c) do the real work in the work item
All of these magic are not needed for synchronous IO.
Filesystems behave this way.
Maxim Shatskih, Windows DDK MVP
StorageCraft Corporation
xxxxx@storagecraft.com
http://www.storagecraft.com