1AIO(7)                     Linux Programmer's Manual                    AIO(7)
2
3
4

NAME

6       aio - POSIX asynchronous I/O overview
7

DESCRIPTION

9       The  POSIX asynchronous I/O (AIO) interface allows applications to ini‐
10       tiate one or more I/O  operations  that  are  performed  asynchronously
11       (i.e., in the background).  The application can elect to be notified of
12       completion of the I/O operation in a variety of ways: by delivery of  a
13       signal, by instantiation of a thread, or no notification at all.
14
15       The POSIX AIO interface consists of the following functions:
16
17       aio_read(3)     Enqueue  a read request.  This is the asynchronous ana‐
18                       log of read(2).
19
20       aio_write(3)    Enqueue a write request.  This is the asynchronous ana‐
21                       log of write(2).
22
23       aio_fsync(3)    Enqueue a sync request for the I/O operations on a file
24                       descriptor.   This  is  the  asynchronous   analog   of
25                       fsync(2) and fdatasync(2).
26
27       aio_error(3)    Obtain the error status of an enqueued I/O request.
28
29       aio_return(3)   Obtain the return status of a completed I/O request.
30
31       aio_suspend(3)  Suspend the caller until one or more of a specified set
32                       of I/O requests completes.
33
34       aio_cancel(3)   Attempt to cancel outstanding I/O requests on a  speci‐
35                       fied file descriptor.
36
37       lio_listio(3)   Enqueue  multiple  I/O requests using a single function
38                       call.
39
40       The aiocb ("asynchronous I/O control block") structure defines  parame‐
41       ters  that  control  an  I/O  operation.   An  argument of this type is
42       employed with all of the functions listed above.   This  structure  has
43       the following form:
44
45           #include <aiocb.h>
46
47           struct aiocb {
48               /* The order of these fields is implementation-dependent */
49
50               int             aio_fildes;     /* File descriptor */
51               off_t           aio_offset;     /* File offset */
52               volatile void  *aio_buf;        /* Location of buffer */
53               size_t          aio_nbytes;     /* Length of transfer */
54               int             aio_reqprio;    /* Request priority */
55               struct sigevent aio_sigevent;   /* Notification method */
56               int             aio_lio_opcode; /* Operation to be performed;
57                                                  lio_listio() only */
58
59               /* Various implementation-internal fields not shown */
60           };
61
62           /* Operation codes for 'aio_lio_opcode': */
63
64           enum { LIO_READ, LIO_WRITE, LIO_NOP };
65
66       The fields of this structure are as follows:
67
68       aio_fildes      The file descriptor on which the I/O operation is to be
69                       performed.
70
71       aio_offset      This is the file offset at which the I/O  operation  is
72                       to be performed.
73
74       aio_buf         This  is the buffer used to transfer data for a read or
75                       write operation.
76
77       aio_nbytes      This is the size of the buffer pointed to by aio_buf.
78
79       aio_reqprio     This field specifies a value that  is  subtracted  from
80                       the  calling  thread's  real-time  priority in order t