sysconf(3C) provides information about the number of CPUs on an entire system. The following example provides the granularity of ascertaining the number of CPUs that are defined in a particular application's pools pset.
The key points for this example include the following:
pvals[] should be a NULL terminated array.
pool_query_pool_resources() returns a list of all resources that match the pvals array type pset from the application's pool my_pool. Because a pool can have only one instance of the pset resource, each instance is always returned in nelem. reslist[] contains only one element, the pset resource.
pool_value_t *pvals[2] = {NULL}; /* pvals[] should be NULL terminated */
/* NOTE: Return value checking/error processing omitted */
/* in all examples for brevity */
conf_loc = pool_dynamic_location();
conf = pool_conf_alloc();
pool_conf_open(conf, conf_loc, PO_RDONLY);
my_pool_name = pool_get_binding(getpid());
my_pool = pool_get_pool(conf, my_pool_name);
pvals[0] = pool_value_alloc();
pvals2[2] = { NULL, NULL };
pool_value_set_name(pvals[0], "type");
pool_value_set_string(pvals[0], "pset");
reslist = pool_query_pool_resources(conf, my_pool, &nelem, pvals);
pool_value_free(pvals[0]);
pool_query_resource_components(conf, reslist[0], &nelem, NULL);
printf("pool %s: %u cpu", my_pool_ name, nelem);
pool_conf_close(conf);