25.1 Introduction
When using signal-driven I/O, the kernel
notifies us with a signal when something happens on a descriptor.
Historically, this has been called asynchronous I/O, but the signal-driven I/O
that we will describe is not true asynchronous I/O. The latter is
normally defined as the process performing the I/O operation (say a
read or write), with the kernel returning immediately after the
kernel initiates the I/O operation. The process continues executing
while the I/O takes place. Some form of notification is then
provided to the process when the operation is complete or
encounters an error. We compared the various types of I/O that are
normally available in Section 6.2 and
showed the difference between signal-driven I/O and asynchronous
I/O.
The nonblocking I/O we described in Chapter 16 is not
asynchronous I/O either. With nonblocking I/O, the kernel does not
return after initiating the I/O operation; the kernel returns
immediately only if the operation cannot be completed without
putting the process to sleep.
POSIX provides true asynchronous I/O with its
aio_XXX
functions. These functions let the process specify whether or not a
signal is generated when the I/O completes, and which signal to
generate.
Berkeley-derived implementations support
signal-driven I/O for sockets and terminal devices using the
SIGIO signal. SVR4 supports signal-driven I/O for STREAMS
devices using the SIGPOLL signal, which is then equated to
SIGIO.
|