cc [options] -Kthread file
#include <aio.h>
The asynchronous I/O routines pass information with the request and receive completion status information after the I/O operation has completed. An asynchronous I/O control block structure aiocb is used to specify input parameters and receive completion status information for asynchronous I/O requests. This structure is defined in aio.h and includes the following members:
int aio_fildes; /* file descriptor */ volatile void *aio_buf; /* buffer location */ size_t aio_nbytes; /* length of transfer */ off_t aio_offset; /* file offset */ int aio_reqprio; /* request priority offset */ struct sigevent aio_sigevent; /* signal number and offset */ int aio_lio_opcode; /* listio operation */ int aio_flags; /* flags */
The structure members
aio_fildes
, aio_buf
,
and aio_nbytes
are the same as the
fildes, buf, and nbytes
arguments to read and write.
With aio_read, for example, the caller wishes to read
aio_nbytes
from the file associated with
aio_fildes
into the buffer pointed to by
aio_buf
.
All appropriate structure members
should be set by the caller when
aio_read or aio_write is called.
The aio_sigevent
member defines the notification method to be used on I/O completion.
If aio_sigevent.sigev_notify
is SIGEV_NONE,
no notification is posted on I/O completion, but the error
status for the operation and the return status for the operation shall
be appropriately set.
You may set the
AIO_RAW flag bit in the aio_flags
structure member when
the asynchronous I/O is being done to a raw device partition.
When the AIO_RAW
flag bit is set, asynchronous I/O might possibly be more efficient.
To insure forward compatibility, you must set all unused fields of the aiocb structure to zero. This can be done by using calloc [see malloc(3C)] to allocate the structure. The aio_reqprio and aio_lio_opcode fields should be set to zero.
aiocb also specifies the asynchronous I/O control block that is used by the 64 bit versions of the asynchronous I/O interface routines. This structure, aiocb64, includes the following members:
struct aiocb64 int aio_fildes; volatile void *aio_buf; size_t aio_nbytes; off64_t aio_offset; int aio_reqprio; struct sigevent aio_sigevent; int aio_lio_opcode; int aio_flags;