subr_param.c revision 8747
11541Srgrimes/*
21541Srgrimes * Copyright (c) 1980, 1986, 1989, 1993
31541Srgrimes *	The Regents of the University of California.  All rights reserved.
41541Srgrimes * (c) UNIX System Laboratories, Inc.
51541Srgrimes * All or some portions of this file are derived from material licensed
61541Srgrimes * to the University of California by American Telephone and Telegraph
71541Srgrimes * Co. or Unix System Laboratories, Inc. and are reproduced herein with
81541Srgrimes * the permission of UNIX System Laboratories, Inc.
91541Srgrimes *
101541Srgrimes * Redistribution and use in source and binary forms, with or without
111541Srgrimes * modification, are permitted provided that the following conditions
121541Srgrimes * are met:
131541Srgrimes * 1. Redistributions of source code must retain the above copyright
141541Srgrimes *    notice, this list of conditions and the following disclaimer.
151541Srgrimes * 2. Redistributions in binary form must reproduce the above copyright
161541Srgrimes *    notice, this list of conditions and the following disclaimer in the
171541Srgrimes *    documentation and/or other materials provided with the distribution.
181541Srgrimes * 3. All advertising materials mentioning features or use of this software
191541Srgrimes *    must display the following acknowledgement:
201541Srgrimes *	This product includes software developed by the University of
211541Srgrimes *	California, Berkeley and its contributors.
221541Srgrimes * 4. Neither the name of the University nor the names of its contributors
231541Srgrimes *    may be used to endorse or promote products derived from this software
241541Srgrimes *    without specific prior written permission.
251541Srgrimes *
261541Srgrimes * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
271541Srgrimes * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
281541Srgrimes * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
291541Srgrimes * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
301541Srgrimes * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
311541Srgrimes * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
321541Srgrimes * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
331541Srgrimes * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
341541Srgrimes * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
351541Srgrimes * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
361541Srgrimes * SUCH DAMAGE.
371541Srgrimes *
381541Srgrimes *	@(#)param.c	8.2 (Berkeley) 1/21/94
398747Sdg * $Id: param.c,v 1.8 1995/02/20 19:42:19 guido Exp $
401541Srgrimes */
411541Srgrimes
421541Srgrimes#include <sys/param.h>
431541Srgrimes#include <sys/systm.h>
441541Srgrimes#include <sys/socket.h>
451541Srgrimes#include <sys/proc.h>
461541Srgrimes#include <sys/vnode.h>
471541Srgrimes#include <sys/file.h>
481541Srgrimes#include <sys/callout.h>
491541Srgrimes#include <sys/clist.h>
501541Srgrimes#include <sys/mbuf.h>
511541Srgrimes#include <sys/kernel.h>
521541Srgrimes
531541Srgrimes#include <ufs/ufs/quota.h>
541541Srgrimes
551541Srgrimes#ifdef SYSVSHM
561541Srgrimes#include <machine/vmparam.h>
571541Srgrimes#include <sys/shm.h>
581541Srgrimes#endif
592729Sdfr#ifdef SYSVSEM
602729Sdfr#include "sys/sem.h"
612729Sdfr#endif
622729Sdfr#ifdef SYSVMSG
632729Sdfr#include "sys/msg.h"
642729Sdfr#endif
651541Srgrimes
661541Srgrimes/*
671541Srgrimes * System parameter formulae.
681541Srgrimes *
691541Srgrimes * This file is copied into each directory where we compile
701541Srgrimes * the kernel; it should be modified there to suit local taste
711541Srgrimes * if necessary.
721541Srgrimes *
731541Srgrimes * Compiled with -DHZ=xx -DTIMEZONE=x -DDST=x -DMAXUSERS=xx
741541Srgrimes */
751541Srgrimes
761541Srgrimes#ifndef HZ
771541Srgrimes#define	HZ 100
781541Srgrimes#endif
791541Srgrimesint	hz = HZ;
801541Srgrimesint	tick = 1000000 / HZ;
811541Srgrimesint	tickadj = 30000 / (60 * HZ);		/* can adjust 30ms in 60s */
821541Srgrimesstruct	timezone tz = { TIMEZONE, DST };
831541Srgrimes#define	NPROC (20 + 16 * MAXUSERS)
845455Sdgint	maxproc = NPROC;			/* maximum # of processes */
856577Sguidoint	maxprocperuid = NPROC-1;		/* maximum # of processes per user */
865530Sdgint	maxfiles = NPROC*2;			/* system wide open files limit */
878747Sdgint	maxfilesperproc = NPROC*2;		/* per-process open files limit */
885455Sdgint	ncallout = 16 + NPROC;			/* maximum # of timer events */
898747Sdg
908747Sdg/* maximum # of mbuf clusters */
918747Sdg#ifndef NMBCLUSTERS
928747Sdg#ifdef GATEWAY
938747Sdgint	nmbclusters = 512 + MAXUSERS * 16;
948747Sdg#else
958747Sdgint	nmbclusters = 256 + MAXUSERS * 16;
968747Sdg#endif /* GATEWAY */
978747Sdg#else
981541Srgrimesint	nmbclusters = NMBCLUSTERS;
998747Sdg#endif
1008747Sdg
1011541Srgrimesint	fscale = FSCALE;	/* kernel uses `FSCALE', user uses `fscale' */
1021541Srgrimes
1031541Srgrimes/*
1041541Srgrimes * Values in support of System V compatible shared memory.	XXX
1051541Srgrimes */
1061541Srgrimes#ifdef SYSVSHM
1076492Sjoerg#ifndef SHMMAX
1081541Srgrimes#define	SHMMAX	(SHMMAXPGS*NBPG)
1096492Sjoerg#endif
1106492Sjoerg#ifndef SHMMIN
1111541Srgrimes#define	SHMMIN	1
1126492Sjoerg#endif
1136492Sjoerg#ifndef SHMMNI
1141541Srgrimes#define	SHMMNI	32			/* <= SHMMMNI in shm.h */
1156492Sjoerg#endif
1166492Sjoerg#ifndef SHMSEG
1171541Srgrimes#define	SHMSEG	8
1186492Sjoerg#endif
1196492Sjoerg#ifndef SHMALL
1201541Srgrimes#define	SHMALL	(SHMMAXPGS/CLSIZE)
1216492Sjoerg#endif
1221541Srgrimes
1231541Srgrimesstruct	shminfo shminfo = {
1241541Srgrimes	SHMMAX,
1251541Srgrimes	SHMMIN,
1261541Srgrimes	SHMMNI,
1271541Srgrimes	SHMSEG,
1281541Srgrimes	SHMALL
1291541Srgrimes};
1301541Srgrimes#endif
1311541Srgrimes
1321541Srgrimes/*
1332729Sdfr * Values in support of System V compatible semaphores.
1342729Sdfr */
1352729Sdfr
1362729Sdfr#ifdef SYSVSEM
1372729Sdfr
1382729Sdfrstruct seminfo seminfo = {
1392729Sdfr                SEMMAP,         /* # of entries in semaphore map */
1402729Sdfr                SEMMNI,         /* # of semaphore identifiers */
1412729Sdfr                SEMMNS,         /* # of semaphores in system */
1422729Sdfr                SEMMNU,         /* # of undo structures in system */
1432729Sdfr                SEMMSL,         /* max # of semaphores per id */
1442729Sdfr                SEMOPM,         /* max # of operations per semop call */
1452729Sdfr                SEMUME,         /* max # of undo entries per process */
1462729Sdfr                SEMUSZ,         /* size in bytes of undo structure */
1472729Sdfr                SEMVMX,         /* semaphore maximum value */
1482729Sdfr                SEMAEM          /* adjust on exit max value */
1492729Sdfr};
1502729Sdfr#endif
1512729Sdfr
1522729Sdfr/*
1532729Sdfr * Values in support of System V compatible messages.
1542729Sdfr */
1552729Sdfr
1562729Sdfr#ifdef SYSVMSG
1572729Sdfr
1582729Sdfrstruct msginfo msginfo = {
1592729Sdfr                MSGMAX,         /* max chars in a message */
1602729Sdfr                MSGMNI,         /* # of message queue identifiers */
1612729Sdfr                MSGMNB,         /* max chars in a queue */
1622729Sdfr                MSGTQL,         /* max messages in system */
1632729Sdfr                MSGSSZ,         /* size of a message segment */
1642729Sdfr                		/* (must be small power of 2 greater than 4) */
1652729Sdfr                MSGSEG          /* number of message segments */
1662729Sdfr};
1672729Sdfr#endif
1682729Sdfr
1692729Sdfr/*
1701541Srgrimes * These are initialized at bootstrap time
1711541Srgrimes * to values dependent on memory size
1721541Srgrimes */
1731541Srgrimesint	nbuf, nswbuf;
1741541Srgrimes
1751541Srgrimes/*
1761541Srgrimes * These have to be allocated somewhere; allocating
1771541Srgrimes * them here forces loader errors if this file is omitted
1781541Srgrimes * (if they've been externed everywhere else; hah!).
1791541Srgrimes */
1801541Srgrimesstruct 	callout *callout;
1811541Srgrimesstruct	cblock *cfree;
1821541Srgrimesstruct	buf *buf, *swbuf;
1831541Srgrimeschar	*buffers;
1841541Srgrimes
1851541Srgrimes/*
1861541Srgrimes * Proc/pgrp hashing.
1871541Srgrimes * Here so that hash table sizes can depend on MAXUSERS/NPROC.
1881541Srgrimes * Hash size must be a power of two.
1891541Srgrimes * NOW omission of this file will cause loader errors!
1901541Srgrimes */
1911541Srgrimes
1921541Srgrimes#if NPROC > 1024
1931541Srgrimes#define	PIDHSZ		512
1941541Srgrimes#else
1951541Srgrimes#if NPROC > 512
1961541Srgrimes#define	PIDHSZ		256
1971541Srgrimes#else
1981541Srgrimes#if NPROC > 256
1991541Srgrimes#define	PIDHSZ		128
2001541Srgrimes#else
2011541Srgrimes#define	PIDHSZ		64
2021541Srgrimes#endif
2031541Srgrimes#endif
2041541Srgrimes#endif
2051541Srgrimes
2061541Srgrimesstruct	proc *pidhash[PIDHSZ];
2071541Srgrimesstruct	pgrp *pgrphash[PIDHSZ];
2081541Srgrimesint	pidhashmask = PIDHSZ - 1;
209