The Asynchronous I/O Control Block is the basic operational unit behind
aio. This is required since an arbitrary number of operations can be started at once, and because each operation can be either input or output. This block is represented by the
aiocb structure, which is defined in the
<aio.h> header. The following fields are available for user applications:
off_t aio_offset;
void *aio_buf;
size_t aio_nbytes;
int aio_fildes;
int aio_lio_opcode;
int aio_reqprio;
struct sigevent aio_sigevent;
The fields are:
1.
The aio_offset specifies the implicit file offset at which the I/O operations are performed. This cannot be expected to be the actual read/write offset of the file descriptor.
2.
The aio_buf member is a pointer to the buffer to which data is going to be written or to which the read operation stores data.
3.
The aio_nbytes specifies the length of aio_buf.
4.
The aio_fildes specifies the used file descriptor.
5.
The aio_lio_opcode is used by the lio_listio() function to initialize a list of I/O requests with a single call.
6.
The aio_reqprio member can be used to lower the scheduling priority of an aio operation. This is only available if _POSIX_PRIORITIZED_IO and _POSIX_PRIORITY_SCHEDULING are defined, and the associated file descriptor supports it.
7.
The aio_sigevent member is used to specify how the calling process is notified once an aio operation completes.
The members
aio_buf,
aio_fildes, and
aio_nbytes are conceptually similar to the parameters ‘buf', ‘fildes', and ‘nbytes' used in the standard
read(2) and
write(2) functions. For example, the caller can read
aio_nbytes from a file associated with the file descriptor
aio_fildes into the buffer
aio_buf. All appropriate fields should be initialized by the caller before
aio_read() or
aio_write() is called.