Node:Asynchronous I/O, Next:Control Operations, Previous:Synchronizing I/O, Up:Low-Level I/O
The POSIX.1b standard defines a new set of I/O operations which can
significantly reduce the time an application spends waiting at I/O. The
new functions allow a program to initiate one or more I/O operations and
then immediately resume normal work while the I/O operations are
executed in parallel. This functionality is available if the
unistd.h
file defines the symbol _POSIX_ASYNCHRONOUS_IO
.
These functions are part of the library with realtime functions named
librt
. They are not actually part of the libc
binary.
The implementation of these functions can be done using support in the
kernel (if available) or using an implementation based on threads at
userlevel. In the latter case it might be necessary to link applications
with the thread library libpthread
in addition to librt
.
All AIO operations operate on files which were opened previously. There
might be arbitrarily many operations running for one file. The
asynchronous I/O operations are controlled using a data structure named
struct aiocb
(AIO control block). It is defined in
aio.h
as follows.
struct aiocb | Data Type |
The POSIX.1b standard mandates that the struct aiocb structure
contains at least the members described in the following table. There
might be more elements which are used by the implementation, but
depending on these elements is not portable and is highly deprecated.
_FILE_OFFSET_BITS == 64 on a
32 bit machine this type is in fact struct aiocb64 since the LFS
interface transparently replaces the struct aiocb definition.
|
struct aiocb
. Particularly,
all member names are the same.
struct aiocb64 | Data Type |
_FILE_OFFSET_BITS == 64 on a
32 bit machine this type is available under the name struct
aiocb64 since the LFS replaces transparently the old interface.
|