FreeBSD/Linux Kernel Cross Reference
sys/kern/zalloc.h
1 /*
2 * Mach Operating System
3 * Copyright (c) 1991,1990,1989,1988,1987 Carnegie Mellon University
4 * All Rights Reserved.
5 *
6 * Permission to use, copy, modify and distribute this software and its
7 * documentation is hereby granted, provided that both the copyright
8 * notice and this permission notice appear in all copies of the
9 * software, derivative works or modified versions, and any portions
10 * thereof, and that both notices appear in supporting documentation.
11 *
12 * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
13 * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
14 * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
15 *
16 * Carnegie Mellon requests users of this software to return to
17 *
18 * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
19 * School of Computer Science
20 * Carnegie Mellon University
21 * Pittsburgh PA 15213-3890
22 *
23 * any improvements or extensions that they make and grant Carnegie Mellon
24 * the rights to redistribute these changes.
25 */
26 /*
27 * HISTORY
28 * $Log: zalloc.h,v $
29 * Revision 2.9 91/05/18 14:34:57 rpd
30 * Removed ZALLOC, ZGET, ZFREE.
31 * Moved ADD_TO_ZONE, REMOVE_FROM_ZONE to kern/zalloc.c.
32 * Moved extraneous zone GC declarations to kern/zalloc.c.
33 * [91/03/31 rpd]
34 * Added zdata, zdata_size.
35 * [91/03/22 rpd]
36 *
37 * Revision 2.8 91/05/14 16:50:52 mrt
38 * Correcting copyright
39 *
40 * Revision 2.7 91/02/05 17:31:33 mrt
41 * Changed to new Mach copyright
42 * [91/02/01 16:22:11 mrt]
43 *
44 * Revision 2.6 91/01/08 15:18:37 rpd
45 * Removed COLLECT_ZONE_GARBAGE. Added consider_zone_gc.
46 * [91/01/03 rpd]
47 *
48 * Revision 2.5 90/12/20 16:39:32 jeffreyh
49 * Merged in changes done by jvs@osf from OSF/1
50 * [90/12/10 jeffreyh]
51 *
52 * Revision 2.4 90/06/02 14:57:37 rpd
53 * Use decl_simple_lock_data for the zone structure lock.
54 * [90/04/23 rpd]
55 *
56 * Revision 2.3 89/11/29 14:09:29 af
57 * Now we know that collectible zones worked on mips all the time.
58 * [89/11/16 15:05:58 af]
59 *
60 * Made obvious that mips cannot collect zone garbage for now.
61 * [89/10/28 af]
62 *
63 * Revision 2.2 89/08/11 17:56:27 rwd
64 * Added collectible zones. Collectible zones allow storage to be
65 * returned to system via kmem_free when pages are no longer used.
66 * This option should only be used when zone memory is virtual
67 * (rather than physical as in a MIPS architecture).
68 * [89/07/22 rfr]
69 *
70 * Revision 2.8 89/05/11 14:41:36 gm0w
71 * Added next_zone field, to link all zones onto a list.
72 * [89/05/08 21:35:14 rpd]
73 *
74 * Revision 2.7 89/03/09 20:17:58 rpd
75 * More cleanup.
76 *
77 * Revision 2.6 89/02/25 18:11:22 gm0w
78 * Kernel code cleanup.
79 * Put macros under #indef KERNEL.
80 * [89/02/15 mrt]
81 *
82 * Revision 2.5 89/02/07 01:06:22 mwyoung
83 * Relocated from sys/zalloc.h
84 *
85 * Revision 2.4 89/01/15 16:36:01 rpd
86 * Use decl_simple_lock_data.
87 * [89/01/15 15:20:28 rpd]
88 *
89 * Revision 2.3 88/12/19 02:52:11 mwyoung
90 * Use MACRO_BEGIN and MACRO_END. This corrects a problem
91 * in the ZGET macro under lint.
92 * [88/12/09 mwyoung]
93 *
94 * Revision 2.2 88/08/24 02:56:21 mwyoung
95 * Adjusted include file references.
96 * [88/08/17 02:30:22 mwyoung]
97 *
98 * 8-Jan-88 Rick Rashid (rfr) at Carnegie-Mellon University
99 * Pageable zone lock added. NOTE ZALLOC and ZFREE macros assume
100 * non-pageable zones.
101 *
102 * 30-Sep-87 Michael Young (mwyoung) at Carnegie-Mellon University
103 * Make ZALLOC, ZFREE not macros for lint.
104 *
105 * 12-Sep-87 Avadis Tevanian (avie) at Carnegie-Mellon University
106 * Modified to use a list instead of a queue - no need for expense
107 * of queue. Also removed warning about assembly language hacks as
108 * there are none left that I know of.
109 *
110 * 1-Sep-87 Michael Young (mwyoung) at Carnegie-Mellon University
111 * Added zchange() declaration; added sleepable, exhaustible flags.
112 *
113 * 18-Apr-87 Avadis Tevanian (avie) at Carnegie-Mellon University
114 * Added ZALLOC and ZGET macros, note that the arguments are
115 * different that zalloc and zget due to language restrictions.
116 * For consistency, also made a ZFREE macro, zfree is now always
117 * a procedure call.
118 *
119 * 15-Apr-87 Avadis Tevanian (avie) at Carnegie-Mellon University
120 * Added warning about implementations that inline expand zalloc
121 * and zget.
122 *
123 * 23-Mar-87 Avadis Tevanian (avie) at Carnegie-Mellon University
124 * Simplified zfree macro.
125 *
126 * 9-Mar-87 Michael Young (mwyoung) at Carnegie-Mellon University
127 * Make zfree a macro: a big win on a register-based machine
128 * with expensive procedure call; smaller change elsewhere.
129 *
130 * 3-Mar-87 Michael Young (mwyoung) at Carnegie-Mellon University
131 * Reduce include of "../h/types.h" to "../mach/machine/vm_types.h".
132 *
133 * 12-Feb-87 Robert Sansom (rds) at Carnegie Mellon University
134 * Added zget.
135 *
136 * 12-Jan-87 Michael Young (mwyoung) at Carnegie-Mellon University
137 * Eliminated use of the interlocked queue package.
138 *
139 * 9-Jun-85 Avadis Tevanian (avie) at Carnegie-Mellon University
140 * Created.
141 */
142 /*
143 * File: zalloc.h
144 * Author: Avadis Tevanian, Jr.
145 * Date: 1985
146 *
147 */
148
149 #ifndef _KERN_ZALLOC_H_
150 #define _KERN_ZALLOC_H_
151
152 #include <mach/machine/vm_types.h>
153 #include <kern/lock.h>
154 #include <kern/queue.h>
155
156 /*
157 * A zone is a collection of fixed size blocks for which there
158 * is fast allocation/deallocation access. Kernel routines can
159 * use zones to manage data structures dynamically, creating a zone
160 * for each type of data structure to be managed.
161 *
162 */
163
164 typedef struct zone {
165 decl_simple_lock_data(,lock) /* generic lock */
166 int count; /* Number of elements used now */
167 vm_offset_t free_elements;
168 vm_size_t cur_size; /* current memory utilization */
169 vm_size_t max_size; /* how large can this zone grow */
170 vm_size_t elem_size; /* size of an element */
171 vm_size_t alloc_size; /* size used for more memory */
172 boolean_t doing_alloc; /* is zone expanding now? */
173 char *zone_name; /* a name for the zone */
174 unsigned int
175 /* boolean_t */ pageable :1, /* zone pageable? */
176 /* boolean_t */ sleepable :1, /* sleep if empty? */
177 /* boolean_t */ exhaustible :1, /* merely return if empty? */
178 /* boolean_t */ collectable :1, /* garbage collect empty pages */
179 /* boolean_t */ expandable :1; /* expand zone (with message)? */
180 lock_data_t complex_lock; /* Lock for pageable zones */
181 struct zone * next_zone; /* Link for all-zones list */
182 } *zone_t;
183
184 #define ZONE_NULL ((zone_t) 0)
185
186 extern void zone_gc();
187 extern void consider_zone_gc();
188
189 extern vm_offset_t zalloc();
190 extern vm_offset_t zget();
191 extern zone_t zinit();
192 extern void zfree();
193 extern void zchange();
194 extern void zcollectable();
195
196 extern vm_offset_t zdata;
197 extern vm_offset_t zdata_size;
198
199 extern void zcram();
200 extern void zone_bootstrap();
201 extern void zone_init();
202
203 #endif _KERN_ZALLOC_H_
Cache object: 7b5d94e3d7c8df91039f07ec32023923
|