1MLOCKALL(3P) POSIX Programmer's Manual MLOCKALL(3P)
2
3
4
6 This manual page is part of the POSIX Programmer's Manual. The Linux
7 implementation of this interface may differ (consult the corresponding
8 Linux manual page for details of Linux behavior), or the interface may
9 not be implemented on Linux.
10
11
13 mlockall, munlockall — lock/unlock the address space of a process
14 (REALTIME)
15
17 #include <sys/mman.h>
18
19 int mlockall(int flags);
20 int munlockall(void);
21
23 The mlockall() function shall cause all of the pages mapped by the
24 address space of a process to be memory-resident until unlocked or
25 until the process exits or execs another process image. The flags argu‐
26 ment determines whether the pages to be locked are those currently
27 mapped by the address space of the process, those that are mapped in
28 the future, or both. The flags argument is constructed from the bit‐
29 wise-inclusive OR of one or more of the following symbolic constants,
30 defined in <sys/mman.h>:
31
32 MCL_CURRENT Lock all of the pages currently mapped into the address
33 space of the process.
34
35 MCL_FUTURE Lock all of the pages that become mapped into the address
36 space of the process in the future, when those mappings are
37 established.
38
39 If MCL_FUTURE is specified, and the automatic locking of future map‐
40 pings eventually causes the amount of locked memory to exceed the
41 amount of available physical memory or any other implementation-defined
42 limit, the behavior is implementation-defined. The manner in which the
43 implementation informs the application of these situations is also
44 implementation-defined.
45
46 The munlockall() function shall unlock all currently mapped pages of
47 the address space of the process. Any pages that become mapped into the
48 address space of the process after a call to munlockall() shall not be
49 locked, unless there is an intervening call to mlockall() specifying
50 MCL_FUTURE or a subsequent call to mlockall() specifying MCL_CURRENT.
51 If pages mapped into the address space of the process are also mapped
52 into the address spaces of other processes and are locked by those pro‐
53 cesses, the locks established by the other processes shall be unaf‐
54 fected by a call by this process to munlockall().
55
56 Upon successful return from the mlockall() function that specifies
57 MCL_CURRENT, all currently mapped pages of the address space of the
58 process shall be memory-resident and locked. Upon return from the
59 munlockall() function, all currently mapped pages of the address space
60 of the process shall be unlocked with respect to the address space of
61 the process. The memory residency of unlocked pages is unspecified.
62
63 Appropriate privileges are required to lock process memory with mlock‐
64 all().
65
67 Upon successful completion, the mlockall() function shall return a
68 value of zero. Otherwise, no additional memory shall be locked, and the
69 function shall return a value of −1 and set errno to indicate the
70 error. The effect of failure of mlockall() on previously existing locks
71 in the address space is unspecified.
72
73 If it is supported by the implementation, the munlockall() function
74 shall always return a value of zero. Otherwise, the function shall
75 return a value of −1 and set errno to indicate the error.
76
78 The mlockall() function shall fail if:
79
80 EAGAIN Some or all of the memory identified by the operation could not
81 be locked when the call was made.
82
83 EINVAL The flags argument is zero, or includes unimplemented flags.
84
85 The mlockall() function may fail if:
86
87 ENOMEM Locking all of the pages currently mapped into the address space
88 of the process would exceed an implementation-defined limit on
89 the amount of memory that the process may lock.
90
91 EPERM The calling process does not have appropriate privileges to per‐
92 form the requested operation.
93
94 The following sections are informative.
95
97 None.
98
100 None.
101
103 None.
104
106 None.
107
109 exec, exit(), fork(), mlock(), munmap()
110
111 The Base Definitions volume of POSIX.1‐2008, <sys_mman.h>
112
114 Portions of this text are reprinted and reproduced in electronic form
115 from IEEE Std 1003.1, 2013 Edition, Standard for Information Technology
116 -- Portable Operating System Interface (POSIX), The Open Group Base
117 Specifications Issue 7, Copyright (C) 2013 by the Institute of Electri‐
118 cal and Electronics Engineers, Inc and The Open Group. (This is
119 POSIX.1-2008 with the 2013 Technical Corrigendum 1 applied.) In the
120 event of any discrepancy between this version and the original IEEE and
121 The Open Group Standard, the original IEEE and The Open Group Standard
122 is the referee document. The original Standard can be obtained online
123 at http://www.unix.org/online.html .
124
125 Any typographical or formatting errors that appear in this page are
126 most likely to have been introduced during the conversion of the source
127 files to man page format. To report such errors, see https://www.ker‐
128 nel.org/doc/man-pages/reporting_bugs.html .
129
130
131
132IEEE/The Open Group 2013 MLOCKALL(3P)