]> CyberLeo.Net >> Repos - FreeBSD/releng/10.0.git/blob - share/man/man9/pbuf.9
- Copy stable/10 (r259064) to releng/10.0 as part of the
[FreeBSD/releng/10.0.git] / share / man / man9 / pbuf.9
1 .\"
2 .\" Copyright (C) 2001 Chad David <davidc@acns.ab.ca>. All rights reserved.
3 .\"
4 .\" Redistribution and use in source and binary forms, with or without
5 .\" modification, are permitted provided that the following conditions
6 .\" are met:
7 .\" 1. Redistributions of source code must retain the above copyright
8 .\"    notice(s), this list of conditions and the following disclaimer as
9 .\"    the first lines of this file unmodified other than the possible
10 .\"    addition of one or more copyright notices.
11 .\" 2. Redistributions in binary form must reproduce the above copyright
12 .\"    notice(s), this list of conditions and the following disclaimer in the
13 .\"    documentation and/or other materials provided with the distribution.
14 .\"
15 .\" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER(S) ``AS IS'' AND ANY
16 .\" EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
17 .\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
18 .\" DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) BE LIABLE FOR ANY
19 .\" DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
20 .\" (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
21 .\" SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
22 .\" CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
25 .\" DAMAGE.
26 .\"
27 .\" $FreeBSD$
28 .\"
29 .Dd July 9, 2001
30 .Dt PBUF 9
31 .Os
32 .Sh NAME
33 .Nm pbuf ,
34 .Nm getpbuf ,
35 .Nm trypbuf ,
36 .Nm relpbuf
37 .Nd "functions for managing physical buffers"
38 .Sh SYNOPSIS
39 .In sys/param.h
40 .In sys/systm.h
41 .In sys/bio.h
42 .In sys/buf.h
43 .Ft "struct buf *"
44 .Fn getpbuf "int *pfreecnt"
45 .Ft "struct buf *"
46 .Fn trypbuf "int *pfreecnt"
47 .Ft void
48 .Fn relpbuf "struct buf *bp" "int *pfreecnt"
49 .Sh DESCRIPTION
50 These functions are used to allocate and release physical buffers.
51 .Pp
52 The physical buffers are allocated at system startup and are
53 maintained in a separate pool from the main system buffers.
54 They are intended for use by subsystems that cannot or should not be
55 reliant on the main pool of buffers (for example the swap pager).
56 The system allocates between 16 and 256 physical buffers depending
57 on the amount of memory in the system.
58 .Pp
59 Each subsystem that allocates buffers via these calls is expected
60 to manage its own percentage free counter.
61 If the value is initialized to \-1 the number of buffers available
62 to the subsystem is limited only by the number of physical buffers
63 available.
64 The number of buffers is stored in
65 .Va nswbuf
66 which is defined in
67 .In sys/buf.h
68 and initialized in
69 .Fn cpu_startup .
70 A recommended initialization value is 1/2
71 .Va nswbuf .
72 .Pp
73 The
74 .Fn getpbuf
75 function returns the first available buffer to the user.
76 If there are no buffers available,
77 .Fn getpbuf
78 will sleep waiting for one to become available.
79 If
80 .Fa pfreecnt
81 is zero,
82 .Fn getpbuf
83 will sleep until it increases.
84 .Fa pfreecnt
85 is decremented prior to returning.
86 .Pp
87 The
88 .Fn trypbuf
89 function returns the first available buffer.
90 If there are no buffers available,
91 .Dv NULL
92 is returned.
93 As well, if
94 .Fa pfreecnt
95 is zero,
96 .Dv NULL
97 is returned.
98 .Fa pfreecnt
99 is decremented prior to returning a valid buffer.
100 If
101 .Dv NULL
102 is returned,
103 .Fa pfreecnt
104 is not modified.
105 .Pp
106 The
107 .Fn relpbuf
108 function releases the buffer back to the free list.
109 If the buffers
110 .Va b_rcred
111 or
112 .Va b_wcred
113 structures are not
114 .Dv NULL ,
115 they are freed.
116 See
117 .Xr crfree 9 .
118 .Pp
119 .Fa pfreecnt
120 is incremented prior to returning.
121 .Sh RETURN VALUES
122 .Fn getpbuf
123 and
124 .Fn trypbuf
125 return a pointer to the buffer.
126 In the case of
127 .Fn trypbuf ,
128 .Dv NULL
129 can also be returned indicating that there are no buffers available.
130 .Sh AUTHORS
131 This manual page was written by
132 .An Chad David Aq davidc@acns.ab.ca .