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 booted configuration.
The cpu_get_info() function returns the following information
about the platform CPU configuration in the buffer
pointed to by the info parameter: 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
The CPU sets specified in the ncpu_info_t structure must
have been created 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, including 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.
Furthermore, 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
The information returned by these functions is a snapshot
of the platform/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 cpu_get_num() and cpu_get_max() functions return values
as stated in the DESCRIPTION. These functions always
The cpu_get_info() function fails, it sets errno to one
of the following 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 system.
Functions: cpusetops(3), numa_intro(3)
[ Back ]