#include <aio.h>
int aio_read(struct aiocb *aiocbp);
int aio_write(struct aiocb *aiocbp);
struct aiocb {
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 */
};
struct sigevent {
int sigev_notify; /* notification mode */
int sigev_signo; /* signal number */
union sigval sigev_value; /* signal value */
};
union sigval {
int sival_int; /* integer value */
void *sival_ptr; /* pointer value */
};
Upon enqueuing the request, the calling process reads aiocbp->nbytes from
the file referred to by aiocbp->fildes into the buffer pointed to by aiocbp->aio_buf.
aiocbp->offset marks the absolute position from the beginning of the file
(in bytes) at which the read begins.
aio_write() queues an asynchronous write request, and returns control immediately. Rather than blocking until completion, the write operation continues concurrently with other activity of the process.
Upon enqueuing the request, the calling process writes aiocbp->nbytes from the buffer pointed to by aiocbp->aio_buf into the file referred to by aiocbp->fildes. If O_APPEND is set for aiocbp->fildes, aio_write() operations append to the file in the same order as the calls were made.
If O_APPEND is not set for the file descriptor, then the write operation will occur at the absolute position from the beginning of the file plus aiocbp->offset (in bytes).
These asynchronous operations are submitted at a priority equal to the calling process’ scheduling priority minus aiocbp->aio_reqprio.
aiocb->aio_sigevent defines both the signal to be generated and how the calling process will be notified upon I/O completion. If aio_sigevent.sigev_notify is SIGEV_NONE, then no signal will be posted upon I/O completion, but the error status and the return status for the operation will be set appropriately. If aio_sigevent.sigev_notify is SIGEV_SIGNAL, then the signal specified in aio_sigevent.sigev_signo will be sent to the process. If the SA_SIGINFO flag is set for that signal number, then the signal will be queued to the process and the value specified in aio_sigevent.sigev_value will be the si_value component of the generated signal (see siginfo(5) ).
Applications compiled under Solaris 2.3 and 2.4 and using POSIX aio must be recompiled to work correctly when Solaris supports the Asynchronous Input and Output option.