'\"macro stdmacro
.if n .pH g3c.mlock @(#)mlock	40.13 of 10/27/89
.\" Copyright 1989 AT&T
'\" ident	"@(#)svid_rt:rt_os/mlock	1.2"
.\" @(#)mlock 1.4 88/09/26 SMI;
'\" macro stdmacro
.\" Sun's mlock.3
.nr X
.if \nX=0 .ds x} mlock 3C "" "\&"
.if \nX=1 .ds x} mlock 3C ""
.if \nX=2 .ds x} mlock 3C "" "\&"
.if \nX=3 .ds x} mlock "" "" "\&"
.TH \*(x}
.SH NAME
\f4mlock\f1, \f4munlock\f1 \- lock (or unlock) pages in memory
.SH SYNOPSIS
.ft 4
.nf
#include <sys/types.h>
.sp .5
int mlock(caddr_t addr, size_t len);
.sp .5
int munlock(caddr_t addr, size_t len);
.ft 1
.fi
.SH DESCRIPTION
The function \f4mlock\f1
uses the mappings established for the address range
[\f2addr, addr + len\f1\^)
to identify pages to be locked in memory.
The effect of
\f4mlock(\f2addr\f4, \f2len\f4)\f1
is equivalent to
\f4memcntl(\f2addr\f4, \f2len\f4, MC_LOCK, 0, 0, 0)\f1.
.P
\f4munlock\f1
removes locks established with \f4mlock\f1.
The effect of
\f4munlock(\f2addr\f4, \f2len\f4)\f1
is equivalent to
\f4memcntl(\f2addr\f4, \f2len\f4, MC_UNLOCK, 0, 0, 0)\f1.
.P
Locks established with
\f4mlock\f1
are not inherited by a child process after a 
\f4fork\f1
and are not nested.
.SH SEE ALSO
.na
\f4fork\fP(2),
\f4memcntl\fP(2),
\f4mmap\fP(2),
\f4mlockall\fP(3C),
\f4plock\fP(2),
\f4sysconf\fP(3C).
.ad
.SH DIAGNOSTICS
Upon successful completion, the functions \f4mlock\f1 and 
\f4munlock\f1 return 0; otherwise, they return \-1 
and set \f4errno\f1 to indicate the error.
.SH NOTES
Use of \f4mlock\f1 and \f4munlock\f1 requires that the user have
appropriate privileges.
