home *** CD-ROM | disk | FTP | other *** search
/ Otherware / Otherware_1_SB_Development.iso / amiga / os / bsdss4.tz / bsdss4 / bsdss / server / sys / param.h < prev    next >
Encoding:
C/C++ Source or Header  |  1992-07-09  |  9.4 KB  |  266 lines

  1. /* 
  2.  * Mach Operating System
  3.  * Copyright (c) 1992 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:    param.h,v $
  29.  * Revision 2.2  92/07/08  15:29:36  mrt
  30.  *     Up MAXCOMLEN and MAXINTERP
  31.  *     [92/07/07            rwd]
  32.  * 
  33.  * Revision 2.1  92/04/21  17:17:26  rwd
  34.  * BSDSS
  35.  * 
  36.  *
  37.  */
  38.  
  39. /*-
  40.  * Copyright (c) 1982, 1986, 1989 The Regents of the University of California.
  41.  * All rights reserved.
  42.  *
  43.  * Redistribution and use in source and binary forms, with or without
  44.  * modification, are permitted provided that the following conditions
  45.  * are met:
  46.  * 1. Redistributions of source code must retain the above copyright
  47.  *    notice, this list of conditions and the following disclaimer.
  48.  * 2. Redistributions in binary form must reproduce the above copyright
  49.  *    notice, this list of conditions and the following disclaimer in the
  50.  *    documentation and/or other materials provided with the distribution.
  51.  * 3. All advertising materials mentioning features or use of this software
  52.  *    must display the following acknowledgement:
  53.  *    This product includes software developed by the University of
  54.  *    California, Berkeley and its contributors.
  55.  * 4. Neither the name of the University nor the names of its contributors
  56.  *    may be used to endorse or promote products derived from this software
  57.  *    without specific prior written permission.
  58.  *
  59.  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
  60.  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  61.  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  62.  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
  63.  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  64.  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  65.  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  66.  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  67.  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  68.  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  69.  * SUCH DAMAGE.
  70.  *
  71.  *    @(#)param.h    7.23 (Berkeley) 5/6/91
  72.  */
  73.  
  74. /*#define    BSD    199103    /* March, 1991 system version (year & month) */
  75. #define BSD4_3    1
  76. #define BSD4_4    0.5
  77.  
  78. #ifndef NULL
  79. #define    NULL    0
  80. #endif
  81.  
  82. #ifndef LOCORE
  83. #include <sys/types.h>
  84. #endif
  85.  
  86. /*
  87.  * Machine-independent constants (some used in following include files).
  88.  * Redefined constants are from POSIX 1003.1 limits file.
  89.  *
  90.  * MAXCOMLEN should be >= sizeof(ac_comm) (see <acct.h>)
  91.  * MAXLOGNAME should be >= UT_NAMESIZE (see <utmp.h>)
  92.  */
  93. #include <sys/syslimits.h>
  94.  
  95. #define    MAXCOMLEN    128        /* max command name remembered */
  96. #define    MAXINTERP    128        /* max interpreter file name length */
  97. #define    MAXLOGNAME    12        /* max login name length */
  98. #define    MAXUPRC        CHILD_MAX    /* max simultaneous processes */
  99. #define    NCARGS        ARG_MAX        /* max bytes for an exec function */
  100. #define    NGROUPS        NGROUPS_MAX    /* max number groups */
  101. #define    NOFILE        OPEN_MAX    /* max open files per process */
  102. #define    NOGROUP        65535        /* marker for empty group set member */
  103. #define MAXHOSTNAMELEN    256        /* max hostname size */
  104.  
  105. /* More types and definitions used throughout the kernel. */
  106. #ifdef KERNEL
  107. #include <sys/cdefs.h>
  108. #include <sys/errno.h>
  109. #include <sys/time.h>
  110. #include <sys/resource.h>
  111. #include <sys/ucred.h>
  112. #include <sys/uio.h>
  113. #endif
  114.  
  115. /* Signals. */
  116. #include <sys/signal.h>
  117.  
  118. /* Machine type dependent parameters. */
  119. #include <machine/param.h>
  120. #include <machine/endian.h>
  121. #include <machine/limits.h>
  122.  
  123. /*
  124.  * Priorities.  Note that with 32 run queues, differences less than 4 are
  125.  * insignificant.
  126.  */
  127. #define    PSWP    0
  128. #define    PVM    4
  129. #define    PINOD    8
  130. #define    PRIBIO    16
  131. #define    PVFS    20
  132. #define    PZERO    22        /* No longer magic, shouldn't be here.  XXX */
  133. #define    PSOCK    24
  134. #define    PWAIT    32
  135. #define    PLOCK    36
  136. #define    PPAUSE    40
  137. #define    PUSER    50
  138. #define    MAXPRI    127        /* Priorities range from 0 through MAXPRI. */
  139.  
  140. #define    PRIMASK    0x0ff
  141. #define    PCATCH    0x100        /* OR'd with pri for tsleep to check signals */
  142. #define PSPECL  0x200        /* release cthread */
  143.  
  144. #define    NZERO    0        /* default "nice" */
  145.  
  146. #define    NBPW    sizeof(int)    /* number of bytes per word (integer) */
  147.  
  148. #define    CMASK    022        /* default file mask: S_IWGRP|S_IWOTH */
  149. #define    NODEV    (dev_t)(-1)    /* non-existent device */
  150.  
  151. /*
  152.  * Clustering of hardware pages on machines with ridiculously small
  153.  * page sizes is done here.  The paging subsystem deals with units of
  154.  * CLSIZE pte's describing NBPG (from machine/machparam.h) pages each.
  155.  */
  156. #define    CLBYTES        (CLSIZE*NBPG)
  157. #define    CLOFSET        (CLSIZE*NBPG-1)    /* for clusters, like PGOFSET */
  158. #define    claligned(x)    ((((int)(x))&CLOFSET)==0)
  159. #define    CLOFF        CLOFSET
  160. #define    CLSHIFT        (PGSHIFT+CLSIZELOG2)
  161.  
  162. #if CLSIZE==1
  163. #define    clbase(i)    (i)
  164. #define    clrnd(i)    (i)
  165. #else
  166. /* Give the base virtual address (first of CLSIZE). */
  167. #define    clbase(i)    ((i) &~ (CLSIZE-1))
  168. /* Round a number of clicks up to a whole cluster. */
  169. #define    clrnd(i)    (((i) + (CLSIZE-1)) &~ (CLSIZE-1))
  170. #endif
  171.  
  172. #define    CBLOCK    64        /* Clist block size, must be a power of 2. */
  173. #define    CBSIZE    (CBLOCK - sizeof(struct cblock *))
  174. #define    CROUND    (CBLOCK - 1)    /* Clist rounding. */
  175.  
  176. /*
  177.  * File system parameters and macros.
  178.  *
  179.  * The file system is made out of blocks of at most MAXBSIZE units, with
  180.  * smaller units (fragments) only in the last direct block.  MAXBSIZE
  181.  * primarily determines the size of buffers in the buffer pool.  It may be
  182.  * made larger without any effect on existing file systems; however making
  183.  * it smaller make make some file systems unmountable.
  184.  */
  185. #define    MAXBSIZE    8192
  186. #define MAXFRAG     8
  187. #define    DEV_BSIZE    512
  188. #define    DEV_BSHIFT    9        /* log2(DEV_BSIZE) */
  189. #define BLKDEV_IOSIZE    2048
  190.  
  191. #define    btodb(bytes)             /* calculates (bytes / DEV_BSIZE) */ \
  192.     ((unsigned)(bytes) >> DEV_BSHIFT)
  193. #define    dbtob(db)            /* calculates (db * DEV_BSIZE) */ \
  194.     ((unsigned)(db) << DEV_BSHIFT)
  195.  
  196. /*
  197.  * Map a ``block device block'' to a file system block.
  198.  * This should be device dependent, and will be after we
  199.  * add an entry to cdevsw for that purpose.  For now though
  200.  * just use DEV_BSIZE.
  201.  */
  202. #define    bdbtofsb(bn)    ((bn) / (BLKDEV_IOSIZE/DEV_BSIZE))
  203.  
  204. /*
  205.  * MAXPATHLEN defines the longest permissable path length after expanding
  206.  * symbolic links. It is used to allocate a temporary buffer from the buffer
  207.  * pool in which to do the name expansion, hence should be a power of two,
  208.  * and must be less than or equal to MAXBSIZE.  MAXSYMLINKS defines the
  209.  * maximum number of symbolic links that may be expanded in a path name.
  210.  * It should be set high enough to allow all legitimate uses, but halt
  211.  * infinite loops reasonably quickly.
  212.  */
  213. #define    MAXPATHLEN    PATH_MAX
  214. #define MAXSYMLINKS    8
  215.  
  216. /* Bit map related macros. */
  217. #define    setbit(a,i)    ((a)[(i)/NBBY] |= 1<<((i)%NBBY))
  218. #define    clrbit(a,i)    ((a)[(i)/NBBY] &= ~(1<<((i)%NBBY)))
  219. #define    isset(a,i)    ((a)[(i)/NBBY] & (1<<((i)%NBBY)))
  220. #define    isclr(a,i)    (((a)[(i)/NBBY] & (1<<((i)%NBBY))) == 0)
  221.  
  222. /* Macros for counting and rounding. */
  223. #ifndef howmany
  224. #define    howmany(x, y)    (((x)+((y)-1))/(y))
  225. #endif
  226. #define    roundup(x, y)    ((((x)+((y)-1))/(y))*(y))
  227. #define powerof2(x)    ((((x)-1)&(x))==0)
  228.  
  229. #define    MIN(a,b) (((a)<(b))?(a):(b))
  230. #define    MAX(a,b) (((a)>(b))?(a):(b))
  231. #define min(a,b) MIN((a),(b))
  232. #define max(a,b) MAX((a),(b))
  233. #define imin(a,b) MIN((a),(b))
  234.  
  235. /*
  236.  * Constants for setting the parameters of the kernel memory allocator.
  237.  *
  238.  * 2 ** MINBUCKET is the smallest unit of memory that will be
  239.  * allocated. It must be at least large enough to hold a pointer.
  240.  *
  241.  * Units of memory less or equal to MAXALLOCSAVE will permanently
  242.  * allocate physical memory; requests for these size pieces of
  243.  * memory are quite fast. Allocations greater than MAXALLOCSAVE must
  244.  * always allocate and free physical memory; requests for these
  245.  * size allocations should be done infrequently as they will be slow.
  246.  *
  247.  * Constraints: CLBYTES <= MAXALLOCSAVE <= 2 ** (MINBUCKET + 14), and
  248.  * MAXALLOCSIZE must be a power of two.
  249.  */
  250. #define MINBUCKET    4        /* 4 => min allocation of 16 bytes */
  251. #define MAXALLOCSAVE    (2 * CLBYTES)
  252.  
  253. /*
  254.  * Scale factor for scaled integers used to count %cpu time and load avgs.
  255.  *
  256.  * The number of CPU `tick's that map to a unique `%age' can be expressed
  257.  * by the formula (1 / (2 ^ (FSHIFT - 11))).  The maximum load average that
  258.  * can be calculated (assuming 32 bits) can be closely approximated using
  259.  * the formula (2 ^ (2 * (16 - FSHIFT))) for (FSHIFT < 15).
  260.  *
  261.  * For the scheduler to maintain a 1:1 mapping of CPU `tick' to `%age',
  262.  * FSHIFT must be at least 11; this gives us a maximum load avg of ~1024.
  263.  */
  264. #define    FSHIFT    11        /* bits to right of fixed binary point */
  265. #define FSCALE    (1<<FSHIFT)
  266.