1 .\" $NetBSD: mlockall.2,v 1.11 2003/04/16 13:34:54 wiz Exp $
3 .\" Copyright (c) 1999 The NetBSD Foundation, Inc.
4 .\" All rights reserved.
6 .\" This code is derived from software contributed to The NetBSD Foundation
7 .\" by Jason R. Thorpe of the Numerical Aerospace Simulation Facility,
8 .\" NASA Ames Research Center.
10 .\" Redistribution and use in source and binary forms, with or without
11 .\" modification, are permitted provided that the following conditions
13 .\" 1. Redistributions of source code must retain the above copyright
14 .\" notice, this list of conditions and the following disclaimer.
15 .\" 2. Redistributions in binary form must reproduce the above copyright
16 .\" notice, this list of conditions and the following disclaimer in the
17 .\" documentation and/or other materials provided with the distribution.
19 .\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
20 .\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 .\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 .\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23 .\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 .\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 .\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 .\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 .\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 .\" POSSIBILITY OF SUCH DAMAGE.
39 .Nd lock (unlock) the address space of a process
45 .Fn mlockall "int flags"
51 system call locks into memory the physical pages associated with the
52 address space of a process until the address space is unlocked, the
53 process exits, or execs another program image.
55 The following flags affect the behavior of
57 .Bl -tag -width ".Dv MCL_CURRENT"
59 Lock all pages currently mapped into the process's address space.
61 Lock all pages mapped into the process's address space in the future,
62 at the time the mapping is established.
63 Note that this may cause future mappings to fail if those mappings
64 cause resource limits to be exceeded.
67 Since physical memory is a potentially scarce resource, processes are
68 limited in how much they can lock down.
69 A single process can lock the minimum of a system-wide
78 .Va security.bsd.unprivileged_mlock
79 is set to 0 these calls are only available to the super-user.
82 is set to 1 the per-process
84 resource limit will not be applied for
90 call unlocks any locked memory regions in the process address space.
91 Any regions mapped after an
93 call will not be locked.
95 A return value of 0 indicates that the call
96 succeeded and all pages in the range have either been locked or unlocked.
97 A return value of \-1 indicates an error occurred and the locked
98 status of all pages in the range remains unchanged.
99 In this case, the global location
101 is set to indicate the error.
109 argument is zero, or includes unimplemented flags.
111 Locking the indicated range would exceed either the system or per-process
112 limit for locked memory.
114 Some or all of the memory mapped into the process's address space
115 could not be locked when the call was made.
117 The calling process does not have the appropriate privilege to perform
118 the requested operation.
131 functions are believed to conform to
138 functions first appeared in
141 The per-process resource limit is a limit on the amount of virtual
142 memory locked, while the system-wide limit is for the number of locked
144 Hence a process with two distinct locked mappings of the same physical page
145 counts as 2 pages against the per-process limit and as only a single page