Asynchronous I/O
The POSIX 1003.1 standard defines a set of library functions—listed in Table 16-4—for accessing the files in an asynchronous way. “Asynchronous” essentially means that when a User Mode process invokes a library function to read or write a file, the function terminates as soon as the read or write operation has been enqueued, possibly even before the actual I/O data transfer takes place. The calling process can thus continue its execution while the data is being transferred.
Table 16-4. The POSIX library functions for asynchronous I/O
Function | Description |
---|---|
| Asynchronously reads some data from a file |
| Asynchronously writes some data into a file |
| Requests a flush operation for all outstanding asynchronous I/O operations (does not block) |
| Gets the error code for an outstanding asynchronous I/O operation |
| Gets the return code for a completed asynchronous I/O operation |
| Cancels an outstanding asynchronous I/O operation |
| Suspends the process until at least one of several outstanding I/O operations completes |
Using asynchronous I/O is quite simple. The application opens the
file by means of the usual open( )
system call. Then, it fills up a control block of type
struct aiocb
with the information
describing the requested operation. The most commonly used fields of the
struct aiocb
control block
are:
aio_fildes
The file descriptor of the file (as returned by the
open( )
system call) ...
Get Understanding the Linux Kernel, 3rd Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.