subr_param.c revision 45515
11556Srgrimes/*
21556Srgrimes * Copyright (c) 1980, 1986, 1989, 1993
31556Srgrimes *	The Regents of the University of California.  All rights reserved.
41556Srgrimes * (c) UNIX System Laboratories, Inc.
51556Srgrimes * All or some portions of this file are derived from material licensed
61556Srgrimes * to the University of California by American Telephone and Telegraph
71556Srgrimes * Co. or Unix System Laboratories, Inc. and are reproduced herein with
81556Srgrimes * the permission of UNIX System Laboratories, Inc.
91556Srgrimes *
101556Srgrimes * Redistribution and use in source and binary forms, with or without
111556Srgrimes * modification, are permitted provided that the following conditions
121556Srgrimes * are met:
131556Srgrimes * 1. Redistributions of source code must retain the above copyright
141556Srgrimes *    notice, this list of conditions and the following disclaimer.
151556Srgrimes * 2. Redistributions in binary form must reproduce the above copyright
161556Srgrimes *    notice, this list of conditions and the following disclaimer in the
171556Srgrimes *    documentation and/or other materials provided with the distribution.
181556Srgrimes * 3. All advertising materials mentioning features or use of this software
191556Srgrimes *    must display the following acknowledgement:
201556Srgrimes *	This product includes software developed by the University of
211556Srgrimes *	California, Berkeley and its contributors.
221556Srgrimes * 4. Neither the name of the University nor the names of its contributors
231556Srgrimes *    may be used to endorse or promote products derived from this software
241556Srgrimes *    without specific prior written permission.
251556Srgrimes *
261556Srgrimes * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
271556Srgrimes * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
281556Srgrimes * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
291556Srgrimes * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
301556Srgrimes * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
311556Srgrimes * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
321556Srgrimes * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
331556Srgrimes * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
341556Srgrimes * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
3536152Scharnier * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
3636152Scharnier * SUCH DAMAGE.
3736152Scharnier *
3836152Scharnier *	@(#)param.c	8.3 (Berkeley) 8/20/94
3950471Speter * $Id: param.c,v 1.32 1998/12/14 08:34:54 dillon Exp $
401556Srgrimes */
411556Srgrimes
421556Srgrimes#include <stddef.h>
431556Srgrimes
441556Srgrimes#include "opt_sysvipc.h"
451556Srgrimes#include "opt_param.h"
461556Srgrimes
471556Srgrimes#include <sys/param.h>
481556Srgrimes
491556Srgrimes#ifdef SYSVSHM
501556Srgrimes#include <machine/vmparam.h>
518170Sbde#include <sys/shm.h>
528170Sbde#endif
531556Srgrimes#ifdef SYSVSEM
541556Srgrimes#include <sys/sem.h>
551556Srgrimes#endif
561556Srgrimes#ifdef SYSVMSG
571556Srgrimes#include <sys/msg.h>
5859788Sache#endif
591556Srgrimes
601556Srgrimes/*
611556Srgrimes * System parameter formulae.
621556Srgrimes *
631556Srgrimes * This file is copied into each directory where we compile
641556Srgrimes * the kernel; it should be modified there to suit local taste
651556Srgrimes * if necessary.
661556Srgrimes *
671556Srgrimes * Compiled with -DMAXUSERS=xx
681556Srgrimes */
691556Srgrimes
701556Srgrimes#ifndef HZ
711556Srgrimes#define	HZ 100
721556Srgrimes#endif
731556Srgrimesint	hz = HZ;
741556Srgrimesint	tick = 1000000 / HZ;
758170Sbdeint	tickadj = howmany(30000, 60 * HZ);	/* can adjust 30ms in 60s */
768170Sbde#define	NPROC (20 + 16 * MAXUSERS)
778170Sbde#ifndef MAXFILES
788855Srgrimes#define MAXFILES (NPROC*2)
791556Srgrimes#endif
801556Srgrimesint	maxproc = NPROC;			/* maximum # of processes */
818148Sacheint	maxprocperuid = NPROC-1;		/* maximum # of processes per user */
828148Sacheint	maxfiles = MAXFILES;			/* system wide open files limit */
838148Sacheint	maxfilesperproc = MAXFILES;		/* per-process open files limit */
848855Srgrimesint	ncallout = 16 + NPROC + MAXFILES;	/* maximum # of timer events */
851556Srgrimes
861556Srgrimes/* maximum # of mbuf clusters */
871556Srgrimes#ifndef NMBCLUSTERS
881556Srgrimes#define	NMBCLUSTERS (512 + MAXUSERS * 16)
891556Srgrimes#endif
901556Srgrimesint	nmbclusters = NMBCLUSTERS;
911556Srgrimes
921556Srgrimes#if MAXFILES > NMBCLUSTERS
931556Srgrimes#define	MAXSOCKETS MAXFILES
941556Srgrimes#else
951556Srgrimes#define	MAXSOCKETS NMBCLUSTERS
961556Srgrimes#endif
971556Srgrimesint	maxsockets = MAXSOCKETS;
981556Srgrimes
9959788Sache/* allocate 1/4th amount of virtual address space for mbufs XXX */
1001556Srgrimesint	nmbufs = NMBCLUSTERS * 4;
1011556Srgrimes
1021556Srgrimes/* maximum # of sf_bufs (sendfile(2) zero-copy virtual buffers) */
1038170Sbde#ifndef NSFBUFS
1041556Srgrimes#define	NSFBUFS (512 + MAXUSERS * 16)
1058170Sbde#endif
1068170Sbdeint	nsfbufs = NSFBUFS;
1071556Srgrimes
1081556Srgrimes/*
1091556Srgrimes * Values in support of System V compatible shared memory.	XXX
1101556Srgrimes */
1111556Srgrimes#ifdef SYSVSHM
1121556Srgrimes#ifndef SHMMAX
1131556Srgrimes#define	SHMMAX	(SHMMAXPGS*PAGE_SIZE)
1141556Srgrimes#endif
1151556Srgrimes#ifndef SHMMIN
1161556Srgrimes#define	SHMMIN	1
1171556Srgrimes#endif
1181556Srgrimes#ifndef SHMMNI
1191556Srgrimes#define	SHMMNI	32			/* <= SHMMMNI in shm.h */
1201556Srgrimes#endif
1211556Srgrimes#ifndef SHMSEG
1221556Srgrimes#define	SHMSEG	8
1231556Srgrimes#endif
1241556Srgrimes#ifndef SHMALL
1251556Srgrimes#define	SHMALL	(SHMMAXPGS)
1261556Srgrimes#endif
1271556Srgrimes
1281556Srgrimesstruct	shminfo shminfo = {
1291556Srgrimes	SHMMAX,
1301556Srgrimes	SHMMIN,
1311556Srgrimes	SHMMNI,
1321556Srgrimes	SHMSEG,
1331556Srgrimes	SHMALL
1341556Srgrimes};
1351556Srgrimes#endif
1361556Srgrimes
1371556Srgrimes/*
1381556Srgrimes * Values in support of System V compatible semaphores.
1391556Srgrimes */
1401556Srgrimes
1411556Srgrimes#ifdef SYSVSEM
1421556Srgrimes
1431556Srgrimesstruct seminfo seminfo = {
1441556Srgrimes                SEMMAP,         /* # of entries in semaphore map */
1451556Srgrimes                SEMMNI,         /* # of semaphore identifiers */
1461556Srgrimes                SEMMNS,         /* # of semaphores in system */
1471556Srgrimes                SEMMNU,         /* # of undo structures in system */
1481556Srgrimes                SEMMSL,         /* max # of semaphores per id */
1491556Srgrimes                SEMOPM,         /* max # of operations per semop call */
1501556Srgrimes                SEMUME,         /* max # of undo entries per process */
1511556Srgrimes                SEMUSZ,         /* size in bytes of undo structure */
1521556Srgrimes                SEMVMX,         /* semaphore maximum value */
1531556Srgrimes                SEMAEM          /* adjust on exit max value */
1541556Srgrimes};
1551556Srgrimes#endif
1561556Srgrimes
1571556Srgrimes/*
1581556Srgrimes * Values in support of System V compatible messages.
1591556Srgrimes */
1601556Srgrimes
1611556Srgrimes#ifdef SYSVMSG
1621556Srgrimes
1631556Srgrimesstruct msginfo msginfo = {
1641556Srgrimes                MSGMAX,         /* max chars in a message */
1651556Srgrimes                MSGMNI,         /* # of message queue identifiers */
1661556Srgrimes                MSGMNB,         /* max chars in a queue */
1671556Srgrimes                MSGTQL,         /* max messages in system */
1681556Srgrimes                MSGSSZ,         /* size of a message segment */
1691556Srgrimes                		/* (must be small power of 2 greater than 4) */
1701556Srgrimes                MSGSEG          /* number of message segments */
1711556Srgrimes};
1721556Srgrimes#endif
1731556Srgrimes
1741556Srgrimes/*
1751556Srgrimes * These may be set to nonzero here or by patching.
1768170Sbde * If they are nonzero at bootstrap time then they are
1778170Sbde * initialized to values dependent on the memory size.
1788170Sbde */
1798170Sbde#ifdef	NBUF
1808170Sbdeint	nbuf = NBUF;
1818170Sbde#else
1828170Sbdeint	nbuf = 0;
1838170Sbde#endif
1848170Sbdeint	nswbuf = 0;
1858170Sbde
1868170Sbde/*
1878170Sbde * These have to be allocated somewhere; allocating
1888170Sbde * them here forces loader errors if this file is omitted
1898170Sbde * (if they've been externed everywhere else; hah!).
1901556Srgrimes */
1911556Srgrimesstruct	buf *swbuf;
1921556Srgrimes