1 .\" $NetBSD: madvise.2,v 1.7 1995/12/27 21:17:02 jtc Exp $
3 .\" Copyright (c) 1991, 1993
4 .\" The Regents of the University of California. All rights reserved.
6 .\" Redistribution and use in source and binary forms, with or without
7 .\" modification, are permitted provided that the following conditions
9 .\" 1. Redistributions of source code must retain the above copyright
10 .\" notice, this list of conditions and the following disclaimer.
11 .\" 2. Redistributions in binary form must reproduce the above copyright
12 .\" notice, this list of conditions and the following disclaimer in the
13 .\" documentation and/or other materials provided with the distribution.
14 .\" 3. All advertising materials mentioning features or use of this software
15 .\" must display the following acknowledgement:
16 .\" This product includes software developed by the University of
17 .\" California, Berkeley and its contributors.
18 .\" 4. Neither the name of the University nor the names of its contributors
19 .\" may be used to endorse or promote products derived from this software
20 .\" without specific prior written permission.
22 .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
23 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25 .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
26 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
28 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
29 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34 .\" @(#)madvise.2 8.1 (Berkeley) 6/9/93
42 .Nd give advice about use of memory
44 .Fd #include <sys/mman.h>
60 system call allows a process that has knowledge of its memory behavior
61 to describe it to the system.
62 The advice passed in may be used by the system
63 to alter its virtual memory paging strategy.
64 This advice may improve application and system performance.
65 The behavior specified in
67 can only be one of the following values:
69 .Bl -tag -width MADV_SEQUENTIAL
71 Indicates that the application has no advice to give on its behavior
72 in the specified address range.
73 This is the system default behavior.
77 .It Dv POSIX_MADV_NORMAL
78 Same as MADV_NORMAL but used with
81 .It Dv MADV_SEQUENTIAL
82 Indicates that the application expects to access this address range
83 in a sequential manner.
87 .It Dv POSIX_MADV_SEQUENTIAL
88 Same as MADV_SEQUENTIAL but used with
92 Indicates that the application expects to access this address range
97 .It Dv POSIX_MADV_RANDOM
98 Same as MADV_RANDOM but used with
102 Indicates that the application expects to access this address range soon.
106 .It Dv POSIX_MADV_WILLNEED
107 Same as MADV_WILLNEED but used with
111 Indicates that the application is not expecting
112 to access this address range soon.
116 .It Dv POSIX_MADV_DONTNEED
117 Same as MADV_DONTNEED but used with
121 Indicates that the application will not need the information contained
122 in this address range, so the pages may be reused right away.
123 The address range will remain valid.
127 .It Dv MADV_ZERO_WIRED_PAGES
128 Indicates that the application would like the wired pages in this address
129 range to be zeroed out if the address range is deallocated without first
130 unwiring the pages (i.e. a munmap(2) without a preceding munlock(2) or the application
141 except that it uses values with POSIX_ prefix for the
143 system call argument.
145 Upon successful completion,
146 a value of 0 is returned.
147 Otherwise, a value of -1 is returned and
149 is set to indicate the error.
152 fails if one or more of the following are true:
161 The address range includes unallocated regions.
164 The virtual address range specified by the
168 are outside the range allowed for the address space.
171 .Fd #include <sys/types.h>
172 .Fd #include <sys/mman.h>
206 function first appeared in 4.4BSD.
209 function is part of IEEE 1003.1-2001
210 and was first implemented in Mac OS X 10.2.