#include <sys/param.h>
#include <sys/pcpu.h>
#include <sys/sysctl.h>
#include <kvm.h> int
kvm_getmaxcpu (kvm_t *kd); void *
kvm_getpcpu (kvm_t *kd int cpu);
DESCRIPTION
The
kvm_getmaxcpu ();
and
kvm_getpcpu ();
functions are used to access the per-CPU data of active processors in the
kernel indicated by
Fa kd .
The
kvm_getmaxcpu ();
function returns the maximum number of CPUs supported by the kernel.
The
kvm_getpcpu ();
function returns a buffer holding the per-CPU data for a single CPU.
This buffer is described by the
Vt struct pcpu
type.
The caller is responsible for releasing the buffer via a call to
free(3)
when it is no longer needed.
If
Fa cpu
is not active, then
NULL
is returned instead.
CACHING
These functions cache the nlist values for various kernel variables which are
reused in successive calls.
You may call either function with
Fa kd
set to
NULL
to clear this cache.
RETURN VALUES
On success, the
kvm_getmaxcpu ();
function returns the maximum number of CPUs supported by the kernel.
If an error occurs,
it returns -1 instead.
On success, the
kvm_getpcpu ();
function returns a pointer to an allocated buffer or
NULL.
If an error occurs,
it returns -1 instead.
If either function encounters an error,
then an error message may be retrieved via
kvm_geterr3.