subr_param.c revision 6577
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 396577Sguido * $Id: param.c,v 1.7 1995/02/16 11:29:19 joerg 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 */ 876577Sguidoint maxfilesperproc = NPROC*2; /* system wide open files limit */ 885455Sdgint ncallout = 16 + NPROC; /* maximum # of timer events */ 891541Srgrimesint nmbclusters = NMBCLUSTERS; 901541Srgrimesint fscale = FSCALE; /* kernel uses `FSCALE', user uses `fscale' */ 911541Srgrimes 921541Srgrimes/* 931541Srgrimes * Values in support of System V compatible shared memory. XXX 941541Srgrimes */ 951541Srgrimes#ifdef SYSVSHM 966492Sjoerg#ifndef SHMMAX 971541Srgrimes#define SHMMAX (SHMMAXPGS*NBPG) 986492Sjoerg#endif 996492Sjoerg#ifndef SHMMIN 1001541Srgrimes#define SHMMIN 1 1016492Sjoerg#endif 1026492Sjoerg#ifndef SHMMNI 1031541Srgrimes#define SHMMNI 32 /* <= SHMMMNI in shm.h */ 1046492Sjoerg#endif 1056492Sjoerg#ifndef SHMSEG 1061541Srgrimes#define SHMSEG 8 1076492Sjoerg#endif 1086492Sjoerg#ifndef SHMALL 1091541Srgrimes#define SHMALL (SHMMAXPGS/CLSIZE) 1106492Sjoerg#endif 1111541Srgrimes 1121541Srgrimesstruct shminfo shminfo = { 1131541Srgrimes SHMMAX, 1141541Srgrimes SHMMIN, 1151541Srgrimes SHMMNI, 1161541Srgrimes SHMSEG, 1171541Srgrimes SHMALL 1181541Srgrimes}; 1191541Srgrimes#endif 1201541Srgrimes 1211541Srgrimes/* 1222729Sdfr * Values in support of System V compatible semaphores. 1232729Sdfr */ 1242729Sdfr 1252729Sdfr#ifdef SYSVSEM 1262729Sdfr 1272729Sdfrstruct seminfo seminfo = { 1282729Sdfr SEMMAP, /* # of entries in semaphore map */ 1292729Sdfr SEMMNI, /* # of semaphore identifiers */ 1302729Sdfr SEMMNS, /* # of semaphores in system */ 1312729Sdfr SEMMNU, /* # of undo structures in system */ 1322729Sdfr SEMMSL, /* max # of semaphores per id */ 1332729Sdfr SEMOPM, /* max # of operations per semop call */ 1342729Sdfr SEMUME, /* max # of undo entries per process */ 1352729Sdfr SEMUSZ, /* size in bytes of undo structure */ 1362729Sdfr SEMVMX, /* semaphore maximum value */ 1372729Sdfr SEMAEM /* adjust on exit max value */ 1382729Sdfr}; 1392729Sdfr#endif 1402729Sdfr 1412729Sdfr/* 1422729Sdfr * Values in support of System V compatible messages. 1432729Sdfr */ 1442729Sdfr 1452729Sdfr#ifdef SYSVMSG 1462729Sdfr 1472729Sdfrstruct msginfo msginfo = { 1482729Sdfr MSGMAX, /* max chars in a message */ 1492729Sdfr MSGMNI, /* # of message queue identifiers */ 1502729Sdfr MSGMNB, /* max chars in a queue */ 1512729Sdfr MSGTQL, /* max messages in system */ 1522729Sdfr MSGSSZ, /* size of a message segment */ 1532729Sdfr /* (must be small power of 2 greater than 4) */ 1542729Sdfr MSGSEG /* number of message segments */ 1552729Sdfr}; 1562729Sdfr#endif 1572729Sdfr 1582729Sdfr/* 1591541Srgrimes * These are initialized at bootstrap time 1601541Srgrimes * to values dependent on memory size 1611541Srgrimes */ 1621541Srgrimesint nbuf, nswbuf; 1631541Srgrimes 1641541Srgrimes/* 1651541Srgrimes * These have to be allocated somewhere; allocating 1661541Srgrimes * them here forces loader errors if this file is omitted 1671541Srgrimes * (if they've been externed everywhere else; hah!). 1681541Srgrimes */ 1691541Srgrimesstruct callout *callout; 1701541Srgrimesstruct cblock *cfree; 1711541Srgrimesstruct buf *buf, *swbuf; 1721541Srgrimeschar *buffers; 1731541Srgrimes 1741541Srgrimes/* 1751541Srgrimes * Proc/pgrp hashing. 1761541Srgrimes * Here so that hash table sizes can depend on MAXUSERS/NPROC. 1771541Srgrimes * Hash size must be a power of two. 1781541Srgrimes * NOW omission of this file will cause loader errors! 1791541Srgrimes */ 1801541Srgrimes 1811541Srgrimes#if NPROC > 1024 1821541Srgrimes#define PIDHSZ 512 1831541Srgrimes#else 1841541Srgrimes#if NPROC > 512 1851541Srgrimes#define PIDHSZ 256 1861541Srgrimes#else 1871541Srgrimes#if NPROC > 256 1881541Srgrimes#define PIDHSZ 128 1891541Srgrimes#else 1901541Srgrimes#define PIDHSZ 64 1911541Srgrimes#endif 1921541Srgrimes#endif 1931541Srgrimes#endif 1941541Srgrimes 1951541Srgrimesstruct proc *pidhash[PIDHSZ]; 1961541Srgrimesstruct pgrp *pgrphash[PIDHSZ]; 1971541Srgrimesint pidhashmask = PIDHSZ - 1; 198