cpu_get_info, cpu_get_num, cpu_get_max - Query CPU information for the
platform (libc library)
ncpu_info_t *info ); int cpu_get_num(
void ); int cpu_get_max(
Points to an ncpu_info_t buffer to receive the CPU information for the
The cpu_get_info() function returns the following information about the
platform CPU configuration in the buffer pointed to by the info parame‐
ter: Revision number. Maximum number of CPUs supported by the machine
architecture. CPU processor set that is physically plugged into the
system and recognized by the system console. Set of online CPUs in the
caller's partition; that is, the set of CPUs on which the caller can
schedule work. Set of CPUs in the partition that have processes bound
to them. Set of CPUs in the partition whose processor set is marked
for exclusive use.
The CPU sets specified in the ncpu_info_t structure must have been cre‐
ated by the caller prior to the call. If the caller specifies zero for
a CPU set, the function silently ignores filling in data for that set.
The information returned by the cpu_get_info() function is relative to
the caller's partition.
The cpu_get_num() function returns the actual number of CPUs available
in the caller's partition.
The cpu_get_max() function returns the maximum number of CPUs, includ‐
ing unpopulated CPU slots, that can be configured in the system.
A cpu_get_info() call is similar to a getsysinfo(GSI_CPU_INFO, ...)
call. The principal difference is that the main ncpu_info_t structure
fields returned by cpu_get_info() are of type cpuset_t, whereas the
same information returned by getsysinfo()is of type ulong_t. Further‐
more, a getsysinfo(GSI_CPU_INFO, ...) call returns information only
about the first n CPUs, where n is the number of bits in a ulong_t
field, or (sizeof(ulong_t)*8).
For cpu_get_info(), the ncpu_version field of the info argument must be
set to NCPU_INFO_VERSION prior to the call.
The information returned by these functions is a snapshot of the plat‐
form/partition configuration at the time the information is sampled.
The data may be stale by the time the caller uses the information.
The cpu_get_info() function returns the following values: Success.
Failure. In this case, errno is set to indicate the error.
The cpu_get_num() and cpu_get_max() functions return values as stated
in the DESCRIPTION. These functions always complete successfully.
The cpu_get_info() function fails, it sets errno to one of the follow‐
ing values: The info argument or one of the cpuset_t elements, points
to an invalid address. One or more of the cpuset_t elements of the
info argument points to an invalid CPU set, possibly one that was not
created by cpusetcreate(). The version number specified in the
ncpu_version field of the info argument is not recognized by the sys‐
Functions: cpusetops(3), numa_intro(3)cpu_get_info(3)