| DDI_NCPUS_EXPECTED(9F) | Kernel Functions for Drivers | DDI_NCPUS_EXPECTED(9F) |
ddi_ncpus_expected —
obtain the expected number of CPUs in the system
#include
<sys/sunddi.h>
uint_t
ddi_ncpus_expected(void);
illumos DDI specific (illumos DDI).
The
ddi_ncpus_expected()
function returns the number of CPUs that the system is expected to have once
it has finished booting.
Device drivers commonly size resources
such as interrupt vectors, queues, and worker threads based on the number of
CPUs in the system. A driver that attaches while the system is booting, such
as the driver for a boot device, may attach before the additional processors
have been started, at a time when only the boot processor is running.
Counting the running CPUs at that point would size such resources for a
single CPU. While only the boot processor is running, the
ddi_ncpus_expected()
function therefore returns the number of processors that the system is
expected to start during boot. Once further processors are running, it
returns the number of CPUs that are present.
The returned value is an estimate that is intended for sizing purposes. The number of CPUs that are present can change over the lifetime of the system (for example, through processor hotplug), and not every CPU that is present is necessarily online.
The ddi_ncpus_expected() function may be
called from
user,
kernel,
or
interrupt
context.
The ddi_ncpus_expected() function always
succeeds. It returns the expected number of CPUs, which is never less than
1.
| August 4, 2026 | OmniOS |