- Expensive to create and maintain
- Usally the number of processes is small and pooled
- Available in traditional Unix and Windows
- Waster CPU time polling repeatedly when there is nothing else for the issuing process to do
- Essentially single-threaded, so may be unable to exploit I/O parallelism the hardware is capable of
- Select(/poll) loops
- Available in BSD Unix, and almost TCP/IP protocol stack
- Is a variation of polling
- A select loop uses the
selectsystem call to
sleepuntil a condition occurs on a
- Reliable and relatively efficient, depends haveily on the Unix paradigm tha “everything is a file”
selectsystem call allow tuning of the acceptable event set
- Essentially interrupts
- Available in BSD and POSIX Unix
- The main flow of the process could have been interruptted at nearly any point, resulting in inconsistent data structures as seen by the signal handler
- The signal handler is usually not able to issue further asynchronous I/O by itself
- Every blocking system call is potentially interruptible
- The programmer must usually incoroprate retry code at each call
- Callback functions
- Available in classic Mac OS, MVS and Windows
- Bear many of the characteristics of the signal method
- Each I/O request usually can have its own completion function, whereas the signal system has a single callback
- Stack depth can grow unmanageably
- Light-weight processes(LWPs) or threads
- Available in more modern Unixes
- Like the process, but without the data isolation
- Introduce its own problems, requrie kernel-provided synchronizaion mechanisms and thread-safe libraries
- Each LWP use traditional blocking synchronous I/O
- Completion queues/ports
- Available in Microsoft Windows, Solaris, AmigaOS, and DNIX
- I/O requests are issued asynchronously, but notifications of completion are provided via a synchronizing queue mechanism in the order they are completed
- Event flags
- It is essentially a completion queue of depth one
- To simulate the effect of queue ‘depth’, an additional event flag is required for each potential unprocessed (but completed) event, or event information can be lost.
- Channel I/O
- Available in mainframes（大型机） by IBM, Groupe Bull, and Unisys
- Channel I/O is designed to maximize CPU utilization and throughput by offloading most I/O onto a coprocessor（协处理器）
- The coprocessor has onboard DMA, handles device interrupts, is controlled by main CPU, and only interrupts main CPU when it’s truly necessary.
- Registered I/O
- Available in Windows Server 2012 and Windows 8
The vast majority of general-purpose computing hardware relies entirely upon two methods of implementing asynchronous I/O: polling and interrupts.
Usually both methods are used together, the balance depends heavily upon the design of the hardware and its required performance characteristics.
- Pure polling systems are entirely possible, small microcontrollers are often built this way.
- Most general-purpose computing systems rely heavily upon interrupts.
- Hybrid approaches are also possible, wherein an interrupt can trigger the beginning of some burst of asynchronous I/O, and polling is used within the burst itself.
C10K problem 翻译文章句子节选
一个线程服务多个客户端，并使用非阻塞 I/O 和变更就绪通知
1:1 线程 vs M:N 线程