The GetCPUCount procedure returns the number of active/installed CPUs in the system.
Count GetCPUCount( ) |
|
See also: GetSysValue |
If the function succeeds, the return value is the number of CPU (processors) installed in the system. Only the active number is returned so if the system has additional CPUs installed for "Processor on Demand" functionality, those additional CPUs are not included in the count.
If the function fails, the return value is zero.
The return value on single-CPU systems is always 1.
The number of CPUs is typically 1 but a growing number of systems are being installed with multiple processors. The following example retrieves the count of the number of CPU (PowerPC chips) installed in the system.
.....DName+++++++++++EUDS.......Length+TDc.Functions++++++++++++++++++++++++++
D nCPUCount S 10I 0
D szSysName S 10A
.....CSRn01..............OpCode(ex)Extended-factor2++++++++++++++++++++++++++++++
C eval nCPUCount = GetCPUCount
C eval szSysName = GetSysName(0)
This example illustrates the pre-V5R1 calling convention. Procedures, under V4R5 and earlier, that do not require parameters, must be specified without the trailing parentheses. When no parameters are specified for a procedure a left and right parenthesis are normally specified. This is referred to as empty parens. In V5R1 and later, the RPG IV syntax was enhanced to accept empty parens syntax. All RPG xTools procedures that do not require parameters may optionally be specified with a zero (0) following the procedure name to more clearly identify it as a procedure name.
The second line in the above example, illustrates the optionally pre-V5R1 syntax.