1 .\" $NetBSD: mlockall.2,v 1.13 2008/04/30 13:10:51 martin 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.
37 .Nd lock (unlock) the address space of a process
43 .Fn mlockall "int flags"
49 system call locks into memory the physical pages associated with the
50 address space of a process until the address space is unlocked, the
51 process exits, or execs another program image.
53 The following flags affect the behavior of
55 .Bl -tag -width MCL_CURRENT
57 Lock all pages currently mapped into the process's address space.
59 Lock all pages mapped into the process's address space in the future,
60 at the time the mapping is established.
61 Note that this may cause future mappings to fail if those mappings
62 cause resource limits to be exceeded.
65 Since physical memory is a potentially scarce resource, processes are
66 limited in how much they can lock down.
67 A single process can lock the minimum of a system-wide
69 limit and the per-process
75 call unlocks any locked memory regions in the process address space.
76 Any regions mapped after an
78 call will not be locked.
80 A return value of 0 indicates that the call
81 succeeded and all pages in the range have either been locked or unlocked.
82 A return value of \-1 indicates an error occurred and the locked
83 status of all pages in the range remains unchanged.
84 In this case, the global location
86 is set to indicate the error.
94 argument is zero, or includes unimplemented flags.
96 Locking the indicated range would exceed either the system or per-process
97 limit for locked memory.
99 Some or all of the memory mapped into the process's address space
100 could not be locked when the call was made.
102 The calling process does not have the appropriate privilege to perform
103 the requested operation.
123 functions first appeared in
126 The per-process resource limit is a limit on the amount of virtual
127 memory locked, while the system-wide limit is for the number of locked
129 Hence a process with two distinct locked mappings of the same physical page
130 counts as 2 pages against the per-process limit and as only a single page