Number of Processes and Process ID Values on HP-UX

7
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.
An obvious example is a counter in a loop which calls pstat_getproc(2). Such programs fail if
the number of processes exceeds the precision of such a counter.
Checking Against MAXPID, PID_MAX, or 30,000
The MAXPID and PID_MAX constants specify the maximum value for a process identifier (PID). For
11i v3 their value is 1,073,741,823. In releases prior to 11i v1, their value was 30,000. For 11i
v1 and v2, their value was 8,388,607 (however, actual PID values generated by these versions never
exceeded 30,000).
The MAXPID symbolic constant is undocumented but, nonetheless, it has been used in some programs
as the maximum PID value against which other PID values are validated. The PID_MAX symbolic
constant is documented but with the provision that the “Actual limit might be greater than specified
value on certain HP-UX systems” (see limits(5)) . Thus, these symbols should not be used directly
in application program code.
Some programs might use these constants to validate PID (or PGID or SID) values. Such programs, if
compiled on releases prior to 11i v3, fail such validations on systems where PID values are larger
than the MAXPID and PID_MAX value on the release under which they were compiled.
Some program code might equate these values with the maximum number of processes in the system.
These programs can fail if compiled on releases before 11i v1 and if the number of processes
becomes greater than 30,000.
Some programs use the constant 30,000 rather than MAXPID or PID_MAX. These programs are also
vulnerable to failure.
Using Arrays to Track Processes
Because previous releases limited the maximum PID value and number of active processes to 30,000,
some programmers found it convenient to use an array to track processes. The array can simply be
indexed by the PID. Assuming 4-byte elements (32-bit pointers), such an array consumes less than
128 K of virtual memory.
Such an array now needs to be 4 GB, since the maximum PID is 2
30
-1. Allocating such a large array
is likely to waste address space and to cause increased swap space reservation (unless allocated in a
lazy swap region). It also can increase the need for RAM and paging (depending on the distribution
of PIDs, the page size, and available RAM), thereby resulting in lower performance.
Five Decimal Digits
Because PID values traditionally do not exceed 30,000, some programs might be dependent on the
notion that PID values do not exceed five (5) decimal digits. Issues can arise if PIDs are larger than
99,999 for the following reasons:
Programs that parse output from another program based on character position in the line can
fail to parse it correctly when that output contains PID values.