#define POSIX_MADV_NORMAL 1 #define POSIX_MADV_SEQUENTIAL 2 #define POSIX_MADV_RANDOM 3 #define POSIX_MADV_DONTNEED 4 #define POSIX_MADV_WILLNEED 5 int madvise(void *addr, size_t len, int advice);
This syscall gives a hint to the operating system on how the user plans to use the memory range. No access information is changed, this is just a hint for the operating system to do stuff with.
advice can be one of:
POSIX_MADV_NORMALAverage access. The equivalent of not advising anything.
POSIX_MADV_SEQUENTIALMemory will be accessed sequentially from bottom to top.
POSIX_MADV_RANDOMMemory will be accessed with no real pattern, all over the place.
POSIX_MADV_DONTNEEDThis memory range is not needed anymore.
POSIX_MADV_WILLNEEDThis memory range will be needed shortly.
This syscall returns 0 on success and -1 on failure, with errno:
EFAULTThe passed buffers were pointing to invalid memory.