'\"macro stdmacro
.if n .pH g2.mincore @(#)mincore	40.11 of 10/10/89
.\" Copyright 1989 AT&T
.\" @(#)mincore.2 1.4 88/01/20 SMI;
.nr X
.if \nX=0 .ds x} mincore 2 "" "\&"
.if \nX=1 .ds x} mincore 2 ""
.if \nX=2 .ds x} mincore 2 "" "\&"
.if \nX=3 .ds x} mincore "" "" "\&"
.TH \*(x}
.SH NAME
\f4mincore\f1 \- determine residency of memory pages
.SH SYNOPSIS
.nf
.ft 4
#include <unistd.h>
int mincore(caddr_t addr, size_t len, char *vec);
.fi
.SH DESCRIPTION
\f4mincore\f1
returns the primary memory
residency status of pages in the address space
covered by mappings in the range
[\f2addr\fP, \f2addr\fP + \f2len\fP).
The status is returned as a character-per-page in the
character array referenced by
.I \(**vec
(which the system assumes to be large enough to encompass
all the pages in the address range).
The least significant bit of each
character is set to 1 to indicate that the referenced page is in primary
memory, 0 if it is not.
The settings of other bits in each character are
undefined and may contain other information in future implementations.
.P
\f4mincore\fP
returns residency information that is accurate at an instant in time.
Because the system may frequently adjust the set of pages in memory,
this information may quickly be outdated.
Only locked pages are guaranteed to remain in memory; see \f4memcntl\fP(2).
.SH RETURN VALUE
\f4mincore\f1
returns 0 on success, \-1 on failure.
.SH ERRORS
\f4mincore\f1
fails if:
.TP 15
\f4EFAULT\fP
.I \(**vec
includes an out-of-range or otherwise inaccessible address.
.TP
\f4EINVAL\fP
.I addr
is not a multiple of the page size as returned by
\f4sysconf\f1(3C).
.TP
\f4EINVAL\f1
The argument
\f2len\f1
has a value less than or equal to \f40\f1.
.TP
\f4ENOMEM\fP
Addresses in the range
[\f2addr, addr + len\fP\^)
are invalid for the address space of a process, or specify
one or more pages which are not mapped.
.SH SEE ALSO
\f4mlock\fP(3C),
\f4mmap\fP(2),
\f4sysconf\fP(3C).
