1AIO(7) Linux Programmer's Manual AIO(7)
2
3
4
6 aio - POSIX asynchronous I/O overview
7
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)
18 Enqueue a read request. This is the asynchronous analog of
19 read(2).
20
21 aio_write(3)
22 Enqueue a write request. This is the asynchronous analog of
23 write(2).
24
25 aio_fsync(3)
26 Enqueue a sync request for the I/O operations on a file descrip‐
27 tor. This is the asynchronous analog of fsync(2) and fdata‐
28 sync(2).
29
30 aio_error(3)
31 Obtain the error status of an enqueued I/O request.
32
33 aio_return(3)
34 Obtain the return status of a completed I/O request.
35
36 aio_suspend(3)
37 Suspend the caller until one or more of a specified set of I/O
38 requests completes.
39
40 aio_cancel(3)
41 Attempt to cancel outstanding I/O requests on a specified file
42 descriptor.
43
44 lio_listio(3)
45 Enqueue multiple I/O requests using a single function call.
46
47 The aiocb ("asynchronous I/O control block") structure defines parame‐
48 ters that control an I/O operation. An argument of this type is em‐
49 ployed with all of the functions listed above. This structure has the
50 following form:
51
52 #include <aiocb.h>
53
54 struct aiocb {
55 /* The order of these fields is implementation-dependent */
56
57 int aio_fildes; /* File descriptor */
58 off_t aio_offset; /* File offset */
59 volatile void *aio_buf; /* Location of buffer */
60 size_t aio_nbytes; /* Length of transfer */
61 int aio_reqprio; /* Request priority */
62 struct sigevent aio_sigevent; /* Notification method */
63 int aio_lio_opcode; /* Operation to be performed;
64 lio_listio() only */
65
66 /* Various implementation-internal fields not shown */
67 };
68
69 /* Operation codes for 'aio_lio_opcode': */
70
71 enum { LIO_READ, LIO_WRITE, LIO_NOP };
72
73 The fields of this structure are as follows:
74
75 aio_fildes
76 The file descriptor on which the I/O operation is to be per‐
77 formed.
78
79 aio_offset
80 This is the file offset at which the I/O operation is to be per‐
81 formed.
82
83 aio_buf
84 This is the buffer used to transfer data for a read or write op‐
85 eration.
86
87 aio_nbytes
88 This is the size of the