OSDN Git Service

LDP: Update original to LDP v3.79
[linuxjm/LDP_man-pages.git] / original / man2 / mincore.2
1 .\" Copyright (C) 2001 Bert Hubert <ahu@ds9a.nl>
2 .\" and Copyright (C) 2007 Michael Kerrisk <mtk.manpages@gmail.com>
3 .\"
4 .\" %%%LICENSE_START(VERBATIM)
5 .\" Permission is granted to make and distribute verbatim copies of this
6 .\" manual provided the copyright notice and this permission notice are
7 .\" preserved on all copies.
8 .\"
9 .\" Permission is granted to copy and distribute modified versions of this
10 .\" manual under the conditions for verbatim copying, provided that the
11 .\" entire resulting derived work is distributed under the terms of a
12 .\" permission notice identical to this one.
13 .\"
14 .\" Since the Linux kernel and libraries are constantly changing, this
15 .\" manual page may be incorrect or out-of-date.  The author(s) assume no
16 .\" responsibility for errors or omissions, or for damages resulting from
17 .\" the use of the information contained herein.  The author(s) may not
18 .\" have taken the same level of care in the production of this manual,
19 .\" which is licensed free of charge, as they might when working
20 .\" professionally.
21 .\"
22 .\" Formatted or processed versions of this manual, if unaccompanied by
23 .\" the source, must acknowledge the copyright and authors of this work.
24 .\" %%%LICENSE_END
25 .\"
26 .\" Created Sun Jun 3 17:23:32 2001 by bert hubert <ahu@ds9a.nl>
27 .\" Slightly adapted, following comments by Hugh Dickins, aeb, 2001-06-04.
28 .\" Modified, 20 May 2003, Michael Kerrisk <mtk.manpages@gmail.com>
29 .\" Modified, 30 Apr 2004, Michael Kerrisk <mtk.manpages@gmail.com>
30 .\" 2005-04-05 mtk, Fixed error descriptions
31 .\"     after message from <gordon.jin@intel.com>
32 .\" 2007-01-08 mtk, rewrote various parts
33 .\"
34 .TH MINCORE 2 2008-04-22 "Linux" "Linux Programmer's Manual"
35 .SH NAME
36 mincore \- determine whether pages are resident in memory
37 .SH SYNOPSIS
38 .B #include <unistd.h>
39 .br
40 .B #include <sys/mman.h>
41 .sp
42 .BI "int mincore(void *" addr ", size_t " length ", unsigned char *" vec );
43 .sp
44 .in -4n
45 Feature Test Macro Requirements for glibc (see
46 .BR feature_test_macros (7)):
47 .in
48 .sp
49 .BR mincore ():
50 _BSD_SOURCE || _SVID_SOURCE
51 .SH DESCRIPTION
52 .BR mincore ()
53 returns a vector that indicates whether pages
54 of the calling process's virtual memory are resident in core (RAM),
55 and so will not cause a disk access (page fault) if referenced.
56 The kernel returns residency information about the pages
57 starting at the address
58 .IR addr ,
59 and continuing for
60 .I length
61 bytes.
62
63 The
64 .I addr
65 argument must be a multiple of the system page size.
66 The
67 .I length
68 argument need not be a multiple of the page size,
69 but since residency information is returned for whole pages,
70 .I length
71 is effectively rounded up to the next multiple of the page size.
72 One may obtain the page size
73 .RB ( PAGE_SIZE )
74 using
75 .IR sysconf(_SC_PAGESIZE) .
76
77 The
78 .I vec
79 argument must point to an array containing at least
80 .I "(length+PAGE_SIZE\-1) / PAGE_SIZE"
81 bytes.
82 On return,
83 the least significant bit of each byte will be set if
84 the corresponding page is currently resident in memory,
85 and be clear otherwise.
86 (The settings of the other bits in each byte are undefined;
87 these bits are reserved for possible later use.)
88 Of course the information returned in
89 .I vec
90 is only a snapshot: pages that are not
91 locked in memory can come and go at any moment, and the contents of
92 .I vec
93 may already be stale by the time this call returns.
94 .SH RETURN VALUE
95 On success,
96 .BR mincore ()
97 returns zero.
98 On error, \-1 is returned, and
99 .I errno
100 is set appropriately.
101 .SH ERRORS
102 .B EAGAIN
103 kernel is temporarily out of resources.
104 .TP
105 .B EFAULT
106 .I vec
107 points to an invalid address.
108 .TP
109 .B EINVAL
110 .I addr
111 is not a multiple of the page size.
112 .TP
113 .B ENOMEM
114 .I length
115 is greater than
116 .RI ( TASK_SIZE " \- " addr ).
117 (This could occur if a negative value is specified for
118 .IR length ,
119 since that value will be interpreted as a large
120 unsigned integer.)
121 In Linux 2.6.11 and earlier, the error
122 .B EINVAL
123 was returned for this condition.
124 .TP
125 .B ENOMEM
126 .I addr
127 to
128 .I addr
129 +
130 .I length
131 contained unmapped memory.
132 .SH VERSIONS
133 Available since Linux 2.3.99pre1 and glibc 2.2.
134 .SH CONFORMING TO
135 .BR mincore ()
136 is not specified in POSIX.1-2001,
137 and it is not available on all UNIX implementations.
138 .\" It is on at least NetBSD, FreeBSD, OpenBSD, Solaris 8,
139 .\" AIX 5.1, SunOS 4.1
140 .\" .SH HISTORY
141 .\" The
142 .\" .BR mincore ()
143 .\" function first appeared in 4.4BSD.
144 .SH BUGS
145 Before kernel 2.6.21,
146 .BR mincore ()
147 did not return correct information for
148 .B MAP_PRIVATE
149 mappings, or for nonlinear mappings (established using
150 .BR remap_file_pages (2)).
151 .\" Linux (up to now, 2.6.5),
152 .\" .B mincore
153 .\" does not return correct information for MAP_PRIVATE mappings:
154 .\" for a MAP_PRIVATE file mapping,
155 .\" .B mincore
156 .\" returns the residency of the file pages, rather than any
157 .\" modified process-private pages that have been copied on write;
158 .\" for a MAP_PRIVATE mapping of
159 .\" .IR /dev/zero ,
160 .\" .B mincore
161 .\" always reports pages as nonresident;
162 .\" and for a MAP_PRIVATE, MAP_ANONYMOUS mapping,
163 .\" .B mincore
164 .\" always fails with the error
165 .\" .BR ENOMEM .
166 .SH SEE ALSO
167 .BR mlock (2),
168 .BR mmap (2)
169 .SH COLOPHON
170 This page is part of release 3.79 of the Linux
171 .I man-pages
172 project.
173 A description of the project,
174 information about reporting bugs,
175 and the latest version of this page,
176 can be found at
177 \%http://www.kernel.org/doc/man\-pages/.