IO Completion Ports and OVERLAPPED management

Edward83

How win32 manages instances of OVERLAPPED struct in context of two functions:

GetQueuedCompletionStatus
PostQueuedCompletionStatus
  1. When I call GetQueuedCompletionStatus does win32 free instance of OVERLAPPED struct or I must do it by my self?

  2. When I send data with PostQueuedCompletionStatus does win32 copy it to internal structs? When I must free memory of sent data?

  3. Where I could find some picture with scheme of processing of OVERLAPPED data between GetQueuedCompletionStatus, PostQueuedCompletionStatus and IOCP queue?

Len Holgate

The OVERLAPPED structure must exist from when a successful I/O operation (or manual PostQueuedCompletionStatus()) executes until the OVERLAPPED emerges from a call to GetQueuedCompletionStatus().

You are responsible for the lifetime of the structure.

You'll see from the MSDN docs that GetQueuedCompletionStatus() actually takes "a pointer to a variable that receives the address of the OVERLAPPED structure that was specified when the completed I/O operation was started.". What you actually get out of that call is a pointer to the original OVERLAPPED that you passed when you made the PostQueuedCompletionStatus() call (or initiated an overlapped I/O operation).

This is all actually very useful as the "normal" way to use the OVERLAPPED structure is to place it inside a larger structure which holds all of the 'per operation' information that you might need - so it's the ideal way to navigate directly from the limited information that you're given when you call GetQueuedCompletionStatus() to, for example, the data buffer that you used in your overlapped read call...

I find the best way to deal with OVERLAPPED structures is to a) embed them in the buffer you're using for read/write b) reference count them and c) return them to a pool for reuse when the ref count drops to 0.

I have some source code that you could download (here) which may make this a little easier to understand (it's a full IOCP server example so it's a little complex, but it works and shows how these things can be used).

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

IO Completion Ports (IOCP)

From Dev

IO Completion Ports and socket send()

From Dev

IO Completion Ports and socket WSARecv()

From Dev

IO Completion Ports and socket send()

From Dev

IO Completion Ports and socket WSARecv()

From Dev

Asynchronous action methods and IO completion ports

From Dev

How to reregister for IO Completion ports for a handle

From Dev

io completion ports issue with calling multiple wsarecv or wsasend per GetQueuedCompletionStatus

From Dev

Completion key vs extending the OVERLAPPED structure

From Dev

Windows overlapped IO actually blocks

From Dev

Windows overlapped IO vs IO on separate thread

From Dev

Multiple I/O Completion Ports

From Dev

select() equivalence in I/O Completion Ports

From Dev

AVR IO Ports can not be global

From Dev

IO Completion port Linux equivalent

From Dev

Business logic in IO completion Port

From Dev

IO Completion port Linux equivalent

From Dev

How does the operating system post io completion messages for async io

From Dev

How does the operating system post io completion messages for async io

From Dev

ASIO IO completion callbacks order vs the order of actual IO operations

From Dev

Data align when socket recv() then written to file using overlapped_io with FILE_NO_BUFFERING_FLAG

From Dev

Spring IO platform release management

From Dev

What Linux has BSD-ports like package management?

From Dev

I/O Completion Ports *LAST* called callback, or: where it's safe to cleanup things

From Dev

C# How to perform Asynchrounus I/O using Completion Ports with APM-TAP Patterns on WCF Callback?

From Dev

pandas from mac ports ImportError: No module named io.data

From Dev

Visual c++ 2005 'Ports' : is not a member of 'System::IO'

From Dev

Using system.io.ports c# Windows IoT Univeral

From Dev

System.IO.Compression.ZipArchive memory management

Related Related

  1. 1

    IO Completion Ports (IOCP)

  2. 2

    IO Completion Ports and socket send()

  3. 3

    IO Completion Ports and socket WSARecv()

  4. 4

    IO Completion Ports and socket send()

  5. 5

    IO Completion Ports and socket WSARecv()

  6. 6

    Asynchronous action methods and IO completion ports

  7. 7

    How to reregister for IO Completion ports for a handle

  8. 8

    io completion ports issue with calling multiple wsarecv or wsasend per GetQueuedCompletionStatus

  9. 9

    Completion key vs extending the OVERLAPPED structure

  10. 10

    Windows overlapped IO actually blocks

  11. 11

    Windows overlapped IO vs IO on separate thread

  12. 12

    Multiple I/O Completion Ports

  13. 13

    select() equivalence in I/O Completion Ports

  14. 14

    AVR IO Ports can not be global

  15. 15

    IO Completion port Linux equivalent

  16. 16

    Business logic in IO completion Port

  17. 17

    IO Completion port Linux equivalent

  18. 18

    How does the operating system post io completion messages for async io

  19. 19

    How does the operating system post io completion messages for async io

  20. 20

    ASIO IO completion callbacks order vs the order of actual IO operations

  21. 21

    Data align when socket recv() then written to file using overlapped_io with FILE_NO_BUFFERING_FLAG

  22. 22

    Spring IO platform release management

  23. 23

    What Linux has BSD-ports like package management?

  24. 24

    I/O Completion Ports *LAST* called callback, or: where it's safe to cleanup things

  25. 25

    C# How to perform Asynchrounus I/O using Completion Ports with APM-TAP Patterns on WCF Callback?

  26. 26

    pandas from mac ports ImportError: No module named io.data

  27. 27

    Visual c++ 2005 'Ports' : is not a member of 'System::IO'

  28. 28

    Using system.io.ports c# Windows IoT Univeral

  29. 29

    System.IO.Compression.ZipArchive memory management

HotTag

Archive