DDI_NCPUS_EXPECTED(9F) Kernel Functions for Drivers DDI_NCPUS_EXPECTED(9F)

ddi_ncpus_expectedobtain the expected number of CPUs in the system

#include <sys/sunddi.h>

uint_t
ddi_ncpus_expected(void);

illumos DDI specific (illumos DDI).

The () 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 () 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 , , or context.

The ddi_ncpus_expected() function always succeeds. It returns the expected number of CPUs, which is never less than 1.

attach(9E), ddi_intr_get_navail(9F)

August 4, 2026 OmniOS