mlock.3p (4627B)
- '\" et
- .TH MLOCK "3P" 2017 "IEEE/The Open Group" "POSIX Programmer's Manual"
- .\"
- .SH PROLOG
- This manual page is part of the POSIX Programmer's Manual.
- The Linux implementation of this interface may differ (consult
- the corresponding Linux manual page for details of Linux behavior),
- or the interface may not be implemented on Linux.
- .\"
- .SH NAME
- mlock,
- munlock
- \(em lock or unlock a range of process address space
- (\fBREALTIME\fP)
- .SH SYNOPSIS
- .LP
- .nf
- #include <sys/mman.h>
- .P
- int mlock(const void *\fIaddr\fP, size_t \fIlen\fP);
- int munlock(const void *\fIaddr\fP, size_t \fIlen\fP);
- .fi
- .SH DESCRIPTION
- The
- \fImlock\fR()
- function shall cause those whole pages containing any part of the
- address space of the process starting at address
- .IR addr
- and continuing for
- .IR len
- bytes to be memory-resident until unlocked or until the process exits
- or
- .IR exec s
- another process image. The implementation may require that
- .IR addr
- be a multiple of
- {PAGESIZE}.
- .P
- The
- \fImunlock\fR()
- function shall unlock those whole pages containing any part of the
- address space of the process starting at address
- .IR addr
- and continuing for
- .IR len
- bytes, regardless of how many times
- \fImlock\fR()
- has been called by the process for any of the pages in the specified
- range. The implementation may require that
- .IR addr
- be a multiple of
- {PAGESIZE}.
- .P
- If any of the pages in the range specified to a call to
- \fImunlock\fR()
- are also mapped into the address spaces of other processes, any locks
- established on those pages by another process are unaffected by the
- call of this process to
- \fImunlock\fR().
- If any of the pages in the range specified by a call to
- \fImunlock\fR()
- are also mapped into other portions of the address space of the calling
- process outside the range specified, any locks established on those
- pages via the other mappings are also unaffected by this call.
- .P
- Upon successful return from
- \fImlock\fR(),
- pages in the specified range shall be locked and memory-resident. Upon
- successful return from
- \fImunlock\fR(),
- pages in the specified range shall be unlocked with respect to the
- address space of the process. Memory residency of unlocked pages is
- unspecified.
- .P
- Appropriate privileges are required to lock process memory with
- \fImlock\fR().
- .SH "RETURN VALUE"
- Upon successful completion, the
- \fImlock\fR()
- and
- \fImunlock\fR()
- functions shall return a value of zero. Otherwise, no change is made to
- any locks in the address space of the process, and the function shall
- return a value of \-1 and set
- .IR errno
- to indicate the error.
- .SH ERRORS
- The
- \fImlock\fR()
- and
- \fImunlock\fR()
- functions shall fail if:
- .TP
- .BR ENOMEM
- Some or all of the address range specified by the
- .IR addr
- and
- .IR len
- arguments does not correspond to valid mapped pages in the address
- space of the process.
- .P
- The
- \fImlock\fR()
- function shall fail if:
- .TP
- .BR EAGAIN
- Some or all of the memory identified by the operation could not be
- locked when the call was made.
- .P
- The
- \fImlock\fR()
- and
- \fImunlock\fR()
- functions may fail if:
- .TP
- .BR EINVAL
- The
- .IR addr
- argument is not a multiple of
- {PAGESIZE}.
- .P
- The
- \fImlock\fR()
- function may fail if:
- .TP
- .BR ENOMEM
- Locking the pages mapped by the specified range would exceed an
- implementation-defined limit on the amount of memory that the process
- may lock.
- .TP
- .BR EPERM
- The calling process does not have appropriate privileges to perform
- the requested operation.
- .LP
- .IR "The following sections are informative."
- .SH EXAMPLES
- None.
- .SH "APPLICATION USAGE"
- None.
- .SH RATIONALE
- None.
- .SH "FUTURE DIRECTIONS"
- None.
- .SH "SEE ALSO"
- .IR "\fIexec\fR\^",
- .IR "\fIexit\fR\^(\|)",
- .IR "\fIfork\fR\^(\|)",
- .IR "\fImlockall\fR\^(\|)",
- .IR "\fImunmap\fR\^(\|)"
- .P
- The Base Definitions volume of POSIX.1\(hy2017,
- .IR "\fB<sys_mman.h>\fP"
- .\"
- .SH COPYRIGHT
- Portions of this text are reprinted and reproduced in electronic form
- from IEEE Std 1003.1-2017, Standard for Information Technology
- -- Portable Operating System Interface (POSIX), The Open Group Base
- Specifications Issue 7, 2018 Edition,
- Copyright (C) 2018 by the Institute of
- Electrical and Electronics Engineers, Inc and The Open Group.
- In the event of any discrepancy between this version and the original IEEE and
- The Open Group Standard, the original IEEE and The Open Group Standard
- is the referee document. The original Standard can be obtained online at
- http://www.opengroup.org/unix/online.html .
- .PP
- Any typographical or formatting errors that appear
- in this page are most likely
- to have been introduced during the conversion of the source files to
- man page format. To report such errors, see
- https://www.kernel.org/doc/man-pages/reporting_bugs.html .