subr_param.c revision 14328
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 3914328Speter * $Id: param.c,v 1.14 1996/01/04 20:28:02 wollman Exp $ 401541Srgrimes */ 411541Srgrimes 4213226Swollman#include "opt_sysvipc.h" 4314328Speter#include "opt_param.h" 4413226Swollman 451541Srgrimes#include <sys/param.h> 461541Srgrimes#include <sys/systm.h> 471541Srgrimes#include <sys/socket.h> 481541Srgrimes#include <sys/proc.h> 491541Srgrimes#include <sys/vnode.h> 501541Srgrimes#include <sys/file.h> 511541Srgrimes#include <sys/callout.h> 521541Srgrimes#include <sys/clist.h> 531541Srgrimes#include <sys/mbuf.h> 541541Srgrimes#include <sys/kernel.h> 551541Srgrimes 561541Srgrimes#include <ufs/ufs/quota.h> 571541Srgrimes 581541Srgrimes#ifdef SYSVSHM 591541Srgrimes#include <machine/vmparam.h> 601541Srgrimes#include <sys/shm.h> 611541Srgrimes#endif 622729Sdfr#ifdef SYSVSEM 6313226Swollman#include <sys/sem.h> 642729Sdfr#endif 652729Sdfr#ifdef SYSVMSG 6613226Swollman#include <sys/msg.h> 672729Sdfr#endif 681541Srgrimes 691541Srgrimes/* 701541Srgrimes * System parameter formulae. 711541Srgrimes * 721541Srgrimes * This file is copied into each directory where we compile 731541Srgrimes * the kernel; it should be modified there to suit local taste 741541Srgrimes * if necessary. 751541Srgrimes * 769369Sdg * Compiled with -DMAXUSERS=xx 771541Srgrimes */ 781541Srgrimes 791541Srgrimes#ifndef HZ 801541Srgrimes#define HZ 100 811541Srgrimes#endif 821541Srgrimesint hz = HZ; 831541Srgrimesint tick = 1000000 / HZ; 841541Srgrimesint tickadj = 30000 / (60 * HZ); /* can adjust 30ms in 60s */ 851541Srgrimes#define NPROC (20 + 16 * MAXUSERS) 865455Sdgint maxproc = NPROC; /* maximum # of processes */ 876577Sguidoint maxprocperuid = NPROC-1; /* maximum # of processes per user */ 885530Sdgint maxfiles = NPROC*2; /* system wide open files limit */ 898747Sdgint maxfilesperproc = NPROC*2; /* per-process open files limit */ 905455Sdgint ncallout = 16 + NPROC; /* maximum # of timer events */ 918747Sdg 928747Sdg/* maximum # of mbuf clusters */ 938747Sdg#ifndef NMBCLUSTERS 948747Sdgint nmbclusters = 512 + MAXUSERS * 16; 958747Sdg#else 961541Srgrimesint nmbclusters = NMBCLUSTERS; 978747Sdg#endif 988747Sdg 991541Srgrimesint fscale = FSCALE; /* kernel uses `FSCALE', user uses `fscale' */ 1001541Srgrimes 1011541Srgrimes/* 1021541Srgrimes * Values in support of System V compatible shared memory. XXX 1031541Srgrimes */ 1041541Srgrimes#ifdef SYSVSHM 1056492Sjoerg#ifndef SHMMAX 1061541Srgrimes#define SHMMAX (SHMMAXPGS*NBPG) 1076492Sjoerg#endif 1086492Sjoerg#ifndef SHMMIN 1091541Srgrimes#define SHMMIN 1 1106492Sjoerg#endif 1116492Sjoerg#ifndef SHMMNI 1121541Srgrimes#define SHMMNI 32 /* <= SHMMMNI in shm.h */ 1136492Sjoerg#endif 1146492Sjoerg#ifndef SHMSEG 1151541Srgrimes#define SHMSEG 8 1166492Sjoerg#endif 1176492Sjoerg#ifndef SHMALL 1181541Srgrimes#define SHMALL (SHMMAXPGS/CLSIZE) 1196492Sjoerg#endif 1201541Srgrimes 1211541Srgrimesstruct shminfo shminfo = { 1221541Srgrimes SHMMAX, 1231541Srgrimes SHMMIN, 1241541Srgrimes SHMMNI, 1251541Srgrimes SHMSEG, 1261541Srgrimes SHMALL 1271541Srgrimes}; 1281541Srgrimes#endif 1291541Srgrimes 1301541Srgrimes/* 1312729Sdfr * Values in support of System V compatible semaphores. 1322729Sdfr */ 1332729Sdfr 1342729Sdfr#ifdef SYSVSEM 1352729Sdfr 1362729Sdfrstruct seminfo seminfo = { 1372729Sdfr SEMMAP, /* # of entries in semaphore map */ 1382729Sdfr SEMMNI, /* # of semaphore identifiers */ 1392729Sdfr SEMMNS, /* # of semaphores in system */ 1402729Sdfr SEMMNU, /* # of undo structures in system */ 1412729Sdfr SEMMSL, /* max # of semaphores per id */ 1422729Sdfr SEMOPM, /* max # of operations per semop call */ 1432729Sdfr SEMUME, /* max # of undo entries per process */ 1442729Sdfr SEMUSZ, /* size in bytes of undo structure */ 1452729Sdfr SEMVMX, /* semaphore maximum value */ 1462729Sdfr SEMAEM /* adjust on exit max value */ 1472729Sdfr}; 1482729Sdfr#endif 1492729Sdfr 1502729Sdfr/* 1512729Sdfr * Values in support of System V compatible messages. 1522729Sdfr */ 1532729Sdfr 1542729Sdfr#ifdef SYSVMSG 1552729Sdfr 1562729Sdfrstruct msginfo msginfo = { 1572729Sdfr MSGMAX, /* max chars in a message */ 1582729Sdfr MSGMNI, /* # of message queue identifiers */ 1592729Sdfr MSGMNB, /* max chars in a queue */ 1602729Sdfr MSGTQL, /* max messages in system */ 1612729Sdfr MSGSSZ, /* size of a message segment */ 1622729Sdfr /* (must be small power of 2 greater than 4) */ 1632729Sdfr MSGSEG /* number of message segments */ 1642729Sdfr}; 1652729Sdfr#endif 1662729Sdfr 1672729Sdfr/* 1689759Sbde * These may be set to nonzero here or by patching. 1699759Sbde * If they are nonzero at bootstrap time then they are 1709759Sbde * initialized to values dependent on the memory size. 1711541Srgrimes */ 1729759Sbde#ifdef NBUF 1739759Sbdeint nbuf = NBUF; 1749759Sbde#else 1759759Sbdeint nbuf = 0; 1769759Sbde#endif 1779759Sbdeint nswbuf = 0; 1781541Srgrimes 1791541Srgrimes/* 1801541Srgrimes * These have to be allocated somewhere; allocating 1811541Srgrimes * them here forces loader errors if this file is omitted 1821541Srgrimes * (if they've been externed everywhere else; hah!). 1831541Srgrimes */ 1849759Sbdestruct buf *swbuf; 1851541Srgrimes 1861541Srgrimes/* 1871541Srgrimes * Proc/pgrp hashing. 1881541Srgrimes * Here so that hash table sizes can depend on MAXUSERS/NPROC. 1891541Srgrimes * Hash size must be a power of two. 1901541Srgrimes * NOW omission of this file will cause loader errors! 1911541Srgrimes */ 1921541Srgrimes 1931541Srgrimes#if NPROC > 1024 1941541Srgrimes#define PIDHSZ 512 1951541Srgrimes#else 1961541Srgrimes#if NPROC > 512 1971541Srgrimes#define PIDHSZ 256 1981541Srgrimes#else 1991541Srgrimes#if NPROC > 256 2001541Srgrimes#define PIDHSZ 128 2011541Srgrimes#else 2021541Srgrimes#define PIDHSZ 64 2031541Srgrimes#endif 2041541Srgrimes#endif 2051541Srgrimes#endif 2061541Srgrimes 2071541Srgrimesstruct proc *pidhash[PIDHSZ]; 2081541Srgrimesstruct pgrp *pgrphash[PIDHSZ]; 2091541Srgrimesint pidhashmask = PIDHSZ - 1; 210