Windows System Software -- Consulting, Training, Development -- Unique Expertise, Guaranteed Results

Before Posting...
Please check out the Community Guidelines in the Announcements and Administration Category.

Asynchronous I/O

OSR_Community_UserOSR_Community_User Member Posts: 110,217
After sending asynchronous I/O using Readfile()/Writefile() / Deviceiocontrol() from user mode, and wait for I/O completion using waitforsingleobject(event,...), how I/O gets completed
1. will context switch happens, i mean will thread be preempted by another thread?
2. if context switch happens how I/O is completed?
3. when wait is satisfied?
4. how the system sets the event on which user is waiting when I/O completes?
5. will the APC routine queued to APC queue of that thread, if yes when APC routine will be run?

Comments

  • Tim_RobertsTim_Roberts Member - All Emails Posts: 13,007
    xxxxx@gmail.com wrote:
    > After sending asynchronous I/O using Readfile()/Writefile() / Deviceiocontrol() from user mode, and wait for I/O completion using waitforsingleobject(event,...), how I/O gets completed
    > 1. will context switch happens, i mean will thread be preempted by another thread?

    When the last driver in the stack calls IoCompleteRequest, the I/O
    manager fires the event.  This makes the thread "ready to run".  The
    driver has the option of specifying a small priority boost in the
    IoCompleteRequest call.  This is because an app that was waiting for an
    I/O request is often going to submit another one right away, so we might
    as well give it a shot at the CPU so it can go wait again.

     
    > 2. if context switch happens how I/O is completed?

    I'm not sure what you are asking.  The thread is marked "ready to run",
    and then the scheduler runs.  If the waiting thread is now the highest
    priority thread, then a context switch will happen.

     
    > 3. when wait is satisfied?

    Already answered above.


    > 4. how the system sets the event on which user is waiting when I/O completes?

    Just like any other event.  There's no magic here.


    > 5. will the APC routine queued to APC queue of that thread, if yes when APC routine will be run?

    Why does it need an APC?  There's no procedure call required.  The
    thread is blocked, and I/O manager unblocks it.  Just that simple.

    --
    Tim Roberts, xxxxx@probo.com
    Providenza & Boekelheide, Inc.

    Tim Roberts, [email protected]
    Providenza & Boekelheide, Inc.

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Upcoming OSR Seminars
Developing Minifilters 29 July 2019 OSR Seminar Space
Writing WDF Drivers 23 Sept 2019 OSR Seminar Space
Kernel Debugging 21 Oct 2019 OSR Seminar Space
Internals & Software Drivers 18 Nov 2019 Dulles, VA