HP-UX 11i Technical Whitepaper Number of Processes and Process ID Values on HP-UX Revision 1.0 ABSTRACT Effective in HP-UX 11i version 3, the maximum number of allowed processes is greater than in prior versions. The value range for process identifiers (PIDs) is also increased to accommodate more processes. Some existing applications might be coded with built-in assumptions on old process and PID limits. Such applications can fail on configurations that exceed the old limits.
Table of Contents Introduction ................................................................................................................................... 3 Terminology................................................................................................................................... 3 Administrator Notes ........................................................................................................................ 4 Kernel Tunable Parameters.................................
Introduction Effective in HP-UX 11i version 3, the maximum number of allowed processes is greater than in prior versions. To support this increase, the range of values used for process IDs (PIDs) is also increased. Similarly, the range of values used for process group IDs (PGIDs) and session IDs (SIDs) is increased (since these are given the PID value of the group or session leader).
PGID See process group ID. PID See process ID. pid_t Is the C-language programmatic data type used for declaring variables which hold PID values. It has always been and will continue to be a 32-bit integer. Its definition was introduced in HP-UX release 8.0. process group ID This is an integer value which is used as the handle or identifier for a process group. Its value is usually the same as the PID of the group leader process. Also known as PGID. See setpgrp(2).
• • process_id_max – Specifies the maximum value the system should use for PIDs assigned to new processes. Changing it does not affect PIDs already assigned. This tunable parameter first appears in 11i v3. The default value is 30,000 to provide an environment compatible with that of HP-UX versions prior to 11i v3. Increase this tunable when more than 30,000 active processes are needed or if you want PIDs to be reused less frequently.
Use pid_t for PID, PGID, SID Values The pid_t data type should be used in the declaration of all variables that hold PID, PGID, or SID values.3 It has sufficient precision to hold any PID value. Use 32-bit int for Process Counters Programs that maintain counts of the number of active processes in the system, or any subset thereof, should use the 32-bit int or equivalent data type to hold these counts. This provides more than adequate precision so that overflows are not a problem.
Caution: It is possible that a type other than short is used, but where the base type is short. The additional system-defined types (from sys/types.h and sys/_inttypes.h) include: int16_t, uint16_t, int_least16_t, uint_least16_t, ubit16, sbit16,cnt_t,nlink_t,use_t. There might be others in headers included by the specific program’s source code. Using 16-Bit Data Types for Process (or Thread) Counts A program might have some short counter whose value is a function of the number of processes.
• • • Poor aesthetics in output because of misalignment of columns when PIDs use more than the expected five character positions. Poor aesthetics in output because of wrapping around on the standard 80 columns, where it did not previously do so, due to PIDs taking more than five character positions. Running together of adjacent fields making output unreadable. For example, In sprintf("%6d%6d%6d", x, pid, y) the values of the variables x and pid will run together if the PID exceeds five digits.
Some experimental evidence suggests a buffer of 200 entries is optimal when a large number of active processes are present. nproc This is the name of the kernel tunable parameter that specifies the maximum number of simultaneous active processes that can be created on the system. Programs that reference this symbol (for example, via nlist(), tuneinfo() or the kmtune command) might have some dependency on the old limits.
Testing After any program source code update, it is always necessary to validate it for proper operation. That validation should be carried out in the expected operational environments. The following sections describe how to set up environments with large PIDs or with a large number of processes in order to adequately validate updates to support such environments. Testing Large PIDs To validate that programs properly handle large PID values, HP-UX 11i v3 adds the ability to make all PID values large.
else { // leaf level in process tree // just wait for signal sigpause() exit } } main() { setup SIGTERM signal handler setup SIGINT handler level = 0 create_children() } Be sure that your system has sufficient memory to support a large number of processes. Approximately 256 K physical memory per process is recommended for this experiment.7 Thus, 4 GB is required for the test program, in addition to that needed for other system activity and the application to be validated.
© 2007 Hewlett-Packard Development Company, L.P. The information contained herein is subject to change without notice. The only warranties for HP products and services are set forth in the express warranty statements accompanying such products and services. Nothing herein should be construed as constituting an additional warranty. HP shall not be liable for technical or editorial errors or omissions contained herein.