madvise(2)
NAME
madvise − advise the system of a process’ expected paging behavior
SYNOPSIS
#include <sys/mman.h>
int madvise(
caddr_t addr,
size_t len,
int behav );
DESCRIPTION
madvise permits a process to advise the system about its expected future behavior in referencing a mapped file or anonymous memory region. Certain implementations may use this information to optimize use of resources.
addr and len specify the address and length in bytes of the region to which the advice refers. If these are not the address and length of a region created by a successful call to mmap(), madvise() fails with an EINVAL error.
The behav argument is constructed from the bitwise inclusive OR of one or more of the following flags defined in the header <sys/mman.h>:
MADV_NORMAL No further special treatment.
MADV_RANDOM Expect random page references.
MADV_SEQUENTIAL Expect sequential page references.
MADV_WILLNEED Will need these pages.
MADV_DONTNEED Will not need these pages.
MADV_SPACEAVAIL Ensure that resources are reserved.
IMPLEMENTATION NOTES
The current implementation of madvise() is a null operation.
RETURN VALUE
madvise() returns 0 upon success; otherwise, it returns −1 and sets errno to indicate the error.
ERRORS
madvise() fails if any of the following conditions are encountered:
[EFAULT] The range specified by (addr, addr+len) is invalid for a process’ address space.
[EINVAL] addr is not a multiple of the page size as returned by sysconf(_SC_PAGE_SIZE), or behav contains invalid values or incompatible combinations of flags.
[EINVAL] The address range specified by addr and len was not created by a successful call to mmap().
AUTHOR
madvise() was developed by HP and OSF.
SEE ALSO
STANDARDS CONFORMANCE
madvise(): AES
Hewlett-Packard Company — HP-UX Release 9.10: April 1995