9.104 madvise

#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_NORMAL

Average access. The equivalent of not advising anything.

POSIX_MADV_SEQUENTIAL

Memory will be accessed sequentially from bottom to top.

POSIX_MADV_RANDOM

Memory will be accessed with no real pattern, all over the place.

POSIX_MADV_DONTNEED

This memory range is not needed anymore.

POSIX_MADV_WILLNEED

This memory range will be needed shortly.

This syscall returns 0 on success and -1 on failure, with errno:

EFAULT

The passed buffers were pointing to invalid memory.