Annotation of kernel/kern/zalloc.h, revision 1.1.1.1

1.1       root        1: /*
                      2:  * Copyright (c) 1999 Apple Computer, Inc. All rights reserved.
                      3:  *
                      4:  * @APPLE_LICENSE_HEADER_START@
                      5:  * 
                      6:  * Portions Copyright (c) 1999 Apple Computer, Inc.  All Rights
                      7:  * Reserved.  This file contains Original Code and/or Modifications of
                      8:  * Original Code as defined in and that are subject to the Apple Public
                      9:  * Source License Version 1.1 (the "License").  You may not use this file
                     10:  * except in compliance with the License.  Please obtain a copy of the
                     11:  * License at http://www.apple.com/publicsource and read it before using
                     12:  * this file.
                     13:  * 
                     14:  * The Original Code and all software distributed under the License are
                     15:  * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
                     16:  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
                     17:  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
                     18:  * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
                     19:  * License for the specific language governing rights and limitations
                     20:  * under the License.
                     21:  * 
                     22:  * @APPLE_LICENSE_HEADER_END@
                     23:  */
                     24: 
                     25: /* 
                     26:  * Mach Operating System
                     27:  * Copyright (c) 1991,1990,1989,1988,1987 Carnegie Mellon University
                     28:  * All Rights Reserved.
                     29:  * 
                     30:  * Permission to use, copy, modify and distribute this software and its
                     31:  * documentation is hereby granted, provided that both the copyright
                     32:  * notice and this permission notice appear in all copies of the
                     33:  * software, derivative works or modified versions, and any portions
                     34:  * thereof, and that both notices appear in supporting documentation.
                     35:  * 
                     36:  * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
                     37:  * CONDITION.  CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
                     38:  * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
                     39:  * 
                     40:  * Carnegie Mellon requests users of this software to return to
                     41:  * 
                     42:  *  Software Distribution Coordinator  or  [email protected]
                     43:  *  School of Computer Science
                     44:  *  Carnegie Mellon University
                     45:  *  Pittsburgh PA 15213-3890
                     46:  * 
                     47:  * any improvements or extensions that they make and grant Carnegie Mellon
                     48:  * the rights to redistribute these changes.
                     49:  */
                     50: /*
                     51:  * Copyright (c) 1995, 1997 Apple Computer, Inc.
                     52:  *
                     53:  * HISTORY
                     54:  *
                     55:  * 23 June 1995 ? at NeXT
                     56:  *     Pulled over from CMU (MK83), added local
                     57:  *     mods: freespace suballocator and sorted
                     58:  *     zone free lists to reduce fragmentation.
                     59:  */
                     60: /*
                     61:  *     File:   zalloc.h
                     62:  *     Author: Avadis Tevanian, Jr.
                     63:  *     Date:    1985
                     64:  *
                     65:  */
                     66: 
                     67: #ifndef        _KERN_ZALLOC_H_
                     68: #define _KERN_ZALLOC_H_
                     69: 
                     70: #include <mach/machine/vm_types.h>
                     71: #include <kern/lock.h>
                     72: #include <kern/queue.h>
                     73: #include <machdep/machine/machspl.h>
                     74: 
                     75: /*
                     76:  *     A zone is a collection of fixed size blocks for which there
                     77:  *     is fast allocation/deallocation access.  Kernel routines can
                     78:  *     use zones to manage data structures dynamically, creating a zone
                     79:  *     for each type of data structure to be managed.
                     80:  *
                     81:  */
                     82: 
                     83: typedef struct zone {
                     84:        decl_simple_lock_data(,lock)    /* generic lock */
                     85:        spl_t           lock_ipl;
                     86:        int             count;          /* Number of elements used now */
                     87:        vm_offset_t     last_insert;
                     88:        vm_offset_t     free_elements;
                     89:        vm_size_t       cur_size;       /* current memory utilization */
                     90:        vm_size_t       max_size;       /* how large can this zone grow */
                     91:        vm_size_t       elem_size;      /* size of an element */
                     92:        vm_size_t       alloc_size;     /* size used for more memory */
                     93:        boolean_t       doing_alloc;    /* is zone expanding now? */
                     94:        char            *zone_name;     /* a name for the zone */
                     95:        unsigned int
                     96:        /* boolean_t */ pageable :1,    /* zone pageable? */
                     97:        /* boolean_t */ sleepable :1,   /* sleep if empty? */
                     98:        /* boolean_t */ exhaustible :1, /* merely return if empty? */
                     99:        /* boolean_t */ expandable :1;  /* expand zone (with message)? */
                    100:        lock_data_t     complex_lock;   /* Lock for pageable zones */
                    101:        struct zone_free_space *
                    102:                        free_space;     /* where to get new elements from */
                    103:        struct zone *   next_zone;      /* Link for all-zones list */
                    104: } *zone_t;
                    105: 
                    106: #define                ZONE_NULL       ((zone_t) 0)
                    107: 
                    108:                        /* allocate a zone entry and block
                    109:                         * if no space available */
                    110: extern vm_offset_t     zalloc( zone_t          zone);
                    111: 
                    112:                        /* allocate a zone entry and fail
                    113:                         * if zone free list is empty */
                    114: extern vm_offset_t     zget(   zone_t          zone);
                    115: 
                    116:                        /* create a new zone */
                    117: extern zone_t          zinit(  vm_size_t       size,
                    118:                                vm_size_t       max,
                    119:                                vm_size_t       alloc,
                    120:                                boolean_t       pageable,
                    121:                                char            *zone_name);
                    122: 
                    123:                        /* return a zone entry to the
                    124:                         * zone free list */
                    125: extern void            zfree(  zone_t          zone,
                    126:                                vm_offset_t     elem);
                    127: 
                    128:                        /* modify the characteristics of
                    129:                         * an existing zone */
                    130: extern void            zchange(zone_t          zone,
                    131:                                boolean_t       pageable,
                    132:                                boolean_t       sleepable,
                    133:                                boolean_t       exhaustible,
                    134:                                boolean_t       collectable);
                    135: 
                    136:                        /* zones are collectable by default
                    137:                         * and cannot later be changed back to collectable */
                    138: extern void            zcollectable(zone_t     zone);
                    139: 
                    140:                        /* exported to vm_resident module
                    141:                         * to acquire space for bootstrapping */
                    142: extern vm_offset_t     zdata;
                    143: extern vm_offset_t     zdata_size;
                    144: 
                    145:                        /* supply memory directly by freeing
                    146:                         * it into the specified zone */
                    147: extern void            zcram(  zone_t          zone,
                    148:                                vm_offset_t     newmem,
                    149:                                vm_size_t       size);
                    150: 
                    151:                        /* bootstrap the zone system to allow
                    152:                         * static allocation before vm is up */
                    153: extern void            zone_bootstrap(void);
                    154: 
                    155:                        /* create the submap of the kernel_map
                    156:                         * used by this module for dynamic allocation */
                    157: extern void            zone_init(void);
                    158: 
                    159: #endif /* _KERN_ZALLOC_H_ */

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.