| |||||
|
|
Hi all, Today we will have our concluding part of Weekly Study Topics. Finally I have run out of topics, but I do hope sincerely, that they have been beneficial to you all. I would like to introduce you to an OS feature which is extremely crucial as far as asynchronous IO communication is concerned. This is called an IO Completion Port. Don't confuse these with network ports.IO completion port is a logical port on which many IO operations (File, sockets, communication etc.) can be queued and waited on. Whenever an IO operation for the specified IO (given by a file handle) completes, the system sends an IO completion notification packet on the IO completion port. Any thread then waiting for the specified operation can be notified about this.An IO Completion port is usually associated with one or more handles (File handles, socket handles, communication resource handles etc.). You can look at MSDN to find more details about IO Completion Ports.Working with IO Completion is NOT straight forward, there cannot be a simple way to define how you will use IO Completion ports. It's rather a design thing, and you need to carefully design your system, around an IO Completion port to take advantage of it.And if you do design it well, then your system will be many times more efficient than one which does not use IO Completion ports. Whenever you have a situation where there are multiple IO operations on multiple (or single) files, and you need to synchronize the operations from multiple threads, you should definitely have a look at making use of IO Completion ports.As I said, there can't be a simple way to show how you will use IO Completion ports, but I will briefly tell you the API's for IO Completion ports, and you can then refer to MSDN for more details.The API that creates an IO Completion port is CreateIoCompletionPort(). This API can also associate the IO Completion port, with multiple file handles (for completion notification).To get the completion status of an IO operation from a completion port, you can use GetQueuedCompletionStatus(). To post a completion notification, you can use PostQueuedCompletionStatus(). These are the basic API's that are required to work with completion ports, apart from these you may also need help of overlapped structures (we have already covered these).IO Completion ports are the most efficient way to doing IO on multiple IO Sources (Files, sockets etc.). Hence a well designed IO Completion port solution, will be much more efficient than one designed without it. Exercises: 1. Study IO Completion port API's. 2. Study about how IO Completion ports work. 3. Study the IO Completion port samples in PSDK. You will get a good grasp of IO Completion ports by studying the samples in PSDK, so do browse through these once.As I said, I am finally out of the topics for WST. Hence consider this as the concluding one, but I will keep sending you info as and when I get to know a new thing.Thanks again for your time. -Farooque
|