What is Windows' best I/O event notification facility?
By best I mean something that ...
The main difference between epoll and select is that in select() the list of file descriptors to wait on only exists for the duration of a single select() call, and the calling task only stays on the sockets' wait queues for the duration of a single call.
Instead of epoll or kqueue, Windows has its own I/O multiplexer called I/O completion ports (IOCPs). IOCPs are the objects used to poll overlapped I/O for completion.
Kqueue allows one to batch modify watcher states and to retrieve watcher states in a single system call. With epoll, you have to call a system call for every modification. Kqueue also allows one to watch for things like filesystem changes and process state changes, epoll is limited to socket/pipe I/O only.
epoll is a Linux kernel system call for a scalable I/O event notification mechanism, first introduced in version 2.5. 44 of the Linux kernel. Its function is to monitor multiple file descriptors to see whether I/O is possible on any of them.
In Windows, async operations are done by file operation, not by descriptor. There are several ways to wait on file operations to complete asynchronously.
For example, if you want to know when data is available on a network socket, issue an async read request on the socket and when it completes, the data was available and was retrieved.
In Win32, async operations use the OVERLAPPED
structure to contain state about an outstanding IO operation.
WaitForMultipleObjects
to wait on all the events at once. This has the disadvantage of only being able to wait on MAXIMUM_WAIT_OBJECTS
objects at once (64). You can also wait on other types of events at the same time (process/thread termination, mutexes, events, semaphores)ReadFileEx
and WriteFileEx
to queue Asynchronous Procedure Calls (APCs) to the calling thread and SleepEx
(or WaitFor{Single|Multiple}ObjectsEx
) with Alertable TRUE
to receive a notification message for each operation when it completes. This method is similar to an IO completion port, but only works for one thread. The Windows NT kernel makes no distinction between socket, disk file, pipe, etc. file operations internally: all of these options will work with all the file types.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With