HP-UX Reference (11i v2 04/09) - 5 Miscellaneous Topics (vol 9)

a
aio(5) aio(5)
Asynchronous I/O operations which use the request and call back mechanism rather than the threads
mechanism for I/O, are subject to a system-wide limit on the amount of physical memory that can be
locked during asynchronous I/O transfers. This system-wide maximum number of bytes of memory that
can be locked simultaneously for aio requests is tunable. This can be set as a percentage of the physical
memory available on the system. By default, it is set to 10% of the physical memory. In addition to the
system-wide limit, there is a per-process limit which is controlled using the argument
RLIMIT_AIO_MEM
to the getrlimit() and setrlimit() system calls. Further, the amount of memory that can be
locked at a time for any reason, not just for asynchronous I/O, is controlled by the system-wide limit
lockable_mem. Other system activity, including explicit memory locking with
plock() and/or
mlock() interfaces may affect the amount of lockable memory at any given time.
The maximum priority change that can be specified in
aio_reqprio is limited. The maximum priority
change value is tunable. The current maximum value can be obtained using the
sysconf() call with
the argument
_SC_AIO_PRIO_DELTA_MAX
. The default value is 20.
The maximum number of asynchronous I/O operations that can be specified in a single
lio_listio()
call is limited. This limit is tunable. The current maximum value can be obtained using the
sysconf()
call with the argument _SC_AIO_LISTIO_MAX
. The default maximum value is 256.
Some asynchronous I/O operations are also subject to both system-wide and per-process limits on the
number of simultaneously active threads. See pthread (3T).
Programming Limitations and Restrictions
Altering the contents of or deallocating memory associated with the
aiocb referred to by aiocbp or the
buffer referred to by aiocbp->aio_buf
while an asynchronous read operation is outstanding, that is
aio_return() has not been called for the aiocb, may produce unpredictable results.
EXAMPLES
The following code sequence illustrates an asynchronous read operation and polling for completion.
#include <fcntl.h>
#include <errno.h>
#include <aio.h>
char buf[4096];
int retval;
struct aiocb myaiocb;
bzero( &myaiocb, sizeof (struct aiocb));
myaiocb.aio_fildes = open( "/dev/null", O_RDONLY);
myaiocb.aio_offset = 0;
myaiocb.aio_buf = (void *) buf;
myaiocb.aio_nbytes = sizeof (buf);
myaiocb.aio_sigevent.sigev_notify = SIGEV_NONE;
retval = aio_read( &myaiocb );
if (retval) perror("aio:");
/* continue processing */
...
/* wait for completion */
while ( (retval = aio_error( &myaiocb) ) == EINPROGRESS) ;
/* free the aiocb */
retval = aio_return( &myaiocb);
SEE ALSO
aio_cancel(2), aio_error(2), aio_fsync(2), aio_read(2), aio_return(2), aio_suspend(2), aio_write(2), fsync(2),
getrlimit(2), lio_listio(2), read(2), write(2), pthread(3T).
STANDARDS CONFORMANCE
aio: POSIX Realtime Extensions, IEEE Std 1003.1b
HP-UX 11i Version 2: September 2004 4 Hewlett-Packard Company Section 521