Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!utgpu!water!watmath!clyde!cbosgd!ihnp4!ptsfa!ames!sdcsvax!ucsdhub!hp-sdd!hplabs!hpcea!hpfcdc!rml From: rml@hpfcdc.UUCP Newsgroups: comp.unix.questions Subject: Re: Max # of processes. Message-ID: <5740011@hpfcdc.HP.COM> Date: Tue, 7-Jul-87 19:12:29 EDT Article-I.D.: hpfcdc.5740011 Posted: Tue Jul 7 19:12:29 1987 Date-Received: Sat, 11-Jul-87 17:39:50 EDT References: <845@zyx.UUCP> Organization: HP Ft. Collins, Co. Lines: 52 > How can the maximum number of processes in a Unix system be determined? Unfortunately there is currently no portable way to do this. > Our system is HP-UX for HP9000/200 and HP9000/300 I'll assume that the series 200 machines are running some 5.x release (the story is different for earlier releases). > I have previously seen references to a symbol named NPROC, and there is > indeed one of that name referred to in the file /usr/include/sys/space.h, > but it isn't defined anywhere in /usr/include/... (which, it seems to me, > makes that include file quite useless). The number of processes is configurable.is a unique file that is only used during the configuration process. It is included by conf.c (which is built by config in the /etc/conf directory when building a new kernel); the value of NPROC is defined in conf.c. Space.h is indeed not very useful for any other purpose that I know of. > I also thought of using nlist(3) to read the value of the appropriate symbol > from the kernel, but I didn't find any symbol that seemed to be the > right one. The symbol in this case is _nproc. This will work for all 5.x releases for the machines you described. It will generally work on BSD-based systems (with the possible exception of the leading underscore). Of course this or any other use of nlist is decidedly non-portable, even among HP systems. We can't even guarantee that it will continue to work under future releases for the same system, though I see no reason that this wouldn't. Note that _nproc is the total number of process slots in the system, certainly conservative for your purpose. Another variable, _maxuprc, holds the value of another configurable parameter, the maximum number of processes for any user ID (except superuser). > If there isn't a 'static' way to find out, this would do as well: > > int max_no_of_processes (); > Process *proc_table; > proc_table = (Process *) malloc (max_no_of_processes () * sizeof (Process)); The IEEE P1003.1 committee is looking at standardizing an interface of this form (more general to get the values of more system parameters). That is probably the most likely source of a portable mechanism. Standard disclaimer: I'm speaking for myself, not HP, or IEEE, or P1003.1, or... Bob Lenk {ihnp4, hplabs}!hpfcla!rml