subr_param.c revision 14526
1279264Sdelphij/* 296593Smarkm * Copyright (c) 1980, 1986, 1989, 1993 396593Smarkm * The Regents of the University of California. All rights reserved. 4142429Snectar * (c) UNIX System Laboratories, Inc. 596593Smarkm * All or some portions of this file are derived from material licensed 696593Smarkm * to the University of California by American Telephone and Telegraph 796593Smarkm * Co. or Unix System Laboratories, Inc. and are reproduced herein with 896593Smarkm * the permission of UNIX System Laboratories, Inc. 996593Smarkm * 1096593Smarkm * Redistribution and use in source and binary forms, with or without 1196593Smarkm * modification, are permitted provided that the following conditions 1296593Smarkm * are met: 1396593Smarkm * 1. Redistributions of source code must retain the above copyright 1496593Smarkm * notice, this list of conditions and the following disclaimer. 1596593Smarkm * 2. Redistributions in binary form must reproduce the above copyright 1696593Smarkm * notice, this list of conditions and the following disclaimer in the 1796593Smarkm * documentation and/or other materials provided with the distribution. 1896593Smarkm * 3. All advertising materials mentioning features or use of this software 1996593Smarkm * must display the following acknowledgement: 20215698Ssimon * This product includes software developed by the University of 21215698Ssimon * California, Berkeley and its contributors. 22215698Ssimon * 4. Neither the name of the University nor the names of its contributors 23215698Ssimon * may be used to endorse or promote products derived from this software 24215698Ssimon * without specific prior written permission. 2596593Smarkm * 2696593Smarkm * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 2796593Smarkm * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 2896593Smarkm * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 2996593Smarkm * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 3096593Smarkm * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 3196593Smarkm * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 3296593Smarkm * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 3396593Smarkm * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 3496593Smarkm * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 3596593Smarkm * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 3696593Smarkm * SUCH DAMAGE. 3796593Smarkm * 3896593Smarkm * @(#)param.c 8.3 (Berkeley) 8/20/94 3996593Smarkm * $Id: param.c,v 1.15 1996/03/02 18:23:57 peter Exp $ 4096593Smarkm */ 41279264Sdelphij 42279264Sdelphij#include "opt_sysvipc.h" 4396593Smarkm#include "opt_param.h" 4496593Smarkm 45215698Ssimon#include <sys/param.h> 46215698Ssimon#include <sys/systm.h> 47215698Ssimon#include <sys/socket.h> 48215698Ssimon#include <sys/proc.h> 49142429Snectar#include <sys/vnode.h> 50215698Ssimon#include <sys/file.h> 51142429Snectar#include <sys/callout.h> 52142429Snectar#include <sys/clist.h> 53279264Sdelphij#include <sys/mbuf.h> 54279264Sdelphij#include <sys/kernel.h> 55279264Sdelphij 5696593Smarkm#include <ufs/ufs/quota.h> 57279264Sdelphij 58279264Sdelphij#ifdef SYSVSHM 59279264Sdelphij#include <machine/vmparam.h> 60279264Sdelphij#include <sys/shm.h> 61279264Sdelphij#endif 62279264Sdelphij#ifdef SYSVSEM 63215698Ssimon#include <sys/sem.h> 64279264Sdelphij#endif 65279264Sdelphij#ifdef SYSVMSG 66279264Sdelphij#include <sys/msg.h> 67279264Sdelphij#endif 68279264Sdelphij 69215698Ssimon/* 70279264Sdelphij * System parameter formulae. 7196593Smarkm * 7296593Smarkm * This file is copied into each directory where we compile 7396593Smarkm * the kernel; it should be modified there to suit local taste 7496593Smarkm * if necessary. 7596593Smarkm * 7696593Smarkm * Compiled with -DMAXUSERS=xx 7796593Smarkm */ 7896593Smarkm 7996593Smarkm#ifndef HZ 8096593Smarkm#define HZ 100 8196593Smarkm#endif 8296593Smarkmint hz = HZ; 8396593Smarkmint tick = 1000000 / HZ; 8496593Smarkmint tickadj = 30000 / (60 * HZ); /* can adjust 30ms in 60s */ 8596593Smarkm#define NPROC (20 + 16 * MAXUSERS) 8696593Smarkmint maxproc = NPROC; /* maximum # of processes */ 8796593Smarkmint maxprocperuid = NPROC-1; /* maximum # of processes per user */ 8896593Smarkmint maxfiles = NPROC*2; /* system wide open files limit */ 8996593Smarkmint maxfilesperproc = NPROC*2; /* per-process open files limit */ 9096593Smarkmint ncallout = 16 + NPROC; /* maximum # of timer events */ 9196593Smarkm 9296593Smarkm/* maximum # of mbuf clusters */ 9396593Smarkm#ifndef NMBCLUSTERS 9496593Smarkmint nmbclusters = 512 + MAXUSERS * 16; 9596593Smarkm#else 9696593Smarkmint nmbclusters = NMBCLUSTERS; 9796593Smarkm#endif 9896593Smarkm 9996593Smarkmint fscale = FSCALE; /* kernel uses `FSCALE', user uses `fscale' */ 10096593Smarkm 10196593Smarkm/* 10296593Smarkm * Values in support of System V compatible shared memory. XXX 10396593Smarkm */ 10496593Smarkm#ifdef SYSVSHM 10596593Smarkm#ifndef SHMMAX 10696593Smarkm#define SHMMAX (SHMMAXPGS*NBPG) 10796593Smarkm#endif 10896593Smarkm#ifndef SHMMIN 10996593Smarkm#define SHMMIN 1 11096593Smarkm#endif 11196593Smarkm#ifndef SHMMNI 11296593Smarkm#define SHMMNI 32 /* <= SHMMMNI in shm.h */ 11396593Smarkm#endif 11496593Smarkm#ifndef SHMSEG 11596593Smarkm#define SHMSEG 8 11696593Smarkm#endif 11796593Smarkm#ifndef SHMALL 11896593Smarkm#define SHMALL (SHMMAXPGS/CLSIZE) 11996593Smarkm#endif 12096593Smarkm 12196593Smarkmstruct shminfo shminfo = { 12296593Smarkm SHMMAX, 12396593Smarkm SHMMIN, 12496593Smarkm SHMMNI, 12596593Smarkm SHMSEG, 12696593Smarkm SHMALL 12796593Smarkm}; 12896593Smarkm#endif 12996593Smarkm 13096593Smarkm/* 13196593Smarkm * Values in support of System V compatible semaphores. 13296593Smarkm */ 133142429Snectar 13496593Smarkm#ifdef SYSVSEM 135100946Snectar 136279264Sdelphijstruct seminfo seminfo = { 137215698Ssimon SEMMAP, /* # of entries in semaphore map */ 138215698Ssimon SEMMNI, /* # of semaphore identifiers */ 139215698Ssimon SEMMNS, /* # of semaphores in system */ 140215698Ssimon SEMMNU, /* # of undo structures in system */ 14196593Smarkm SEMMSL, /* max # of semaphores per id */ 14296593Smarkm SEMOPM, /* max # of operations per semop call */ 14396593Smarkm SEMUME, /* max # of undo entries per process */ 144142429Snectar SEMUSZ, /* size in bytes of undo structure */ 14596593Smarkm SEMVMX, /* semaphore maximum value */ 14696593Smarkm SEMAEM /* adjust on exit max value */ 14796593Smarkm}; 14896593Smarkm#endif 149215698Ssimon 150215698Ssimon/* 151215698Ssimon * Values in support of System V compatible messages. 152215698Ssimon */ 153215698Ssimon 154215698Ssimon#ifdef SYSVMSG 155215698Ssimon 15696593Smarkmstruct msginfo msginfo = { 15796593Smarkm MSGMAX, /* max chars in a message */ 15896593Smarkm MSGMNI, /* # of message queue identifiers */ 15996593Smarkm MSGMNB, /* max chars in a queue */ 16096593Smarkm MSGTQL, /* max messages in system */ 161215698Ssimon MSGSSZ, /* size of a message segment */ 16296593Smarkm /* (must be small power of 2 greater than 4) */ 16396593Smarkm MSGSEG /* number of message segments */ 16496593Smarkm}; 16596593Smarkm#endif 16696593Smarkm 16796593Smarkm/* 16896593Smarkm * These may be set to nonzero here or by patching. 16996593Smarkm * If they are nonzero at bootstrap time then they are 17096593Smarkm * initialized to values dependent on the memory size. 17196593Smarkm */ 17296593Smarkm#ifdef NBUF 17396593Smarkmint nbuf = NBUF; 17496593Smarkm#else 17596593Smarkmint nbuf = 0; 17696593Smarkm#endif 17796593Smarkmint nswbuf = 0; 17896593Smarkm 17996593Smarkm/* 18096593Smarkm * These have to be allocated somewhere; allocating 18196593Smarkm * them here forces loader errors if this file is omitted 18296593Smarkm * (if they've been externed everywhere else; hah!). 18396593Smarkm */ 18496593Smarkmstruct buf *swbuf; 185215698Ssimon