Source
/* https://stackoverflow.com/questions/28098082/unable-to-use-more-than-one-processor-group-for-my-threads-in-a-c-sharp-app */
/*
** Copyright (C) 2001-2025 Zabbix SIA
**
** This program is free software: you can redistribute it and/or modify it under the terms of
** the GNU Affero General Public License as published by the Free Software Foundation, version 3.
**
** This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
** without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
** See the GNU Affero General Public License for more details.
**
** You should have received a copy of the GNU Affero General Public License along with this program.
** If not, see <https://www.gnu.org/licenses/>.
**/
/* StringCchPrintf */
/* <sys/dkstat.h> removed in OpenBSD 5.7, only <sys/sched.h> with the same CP_* definitions remained */
static zbx_mutex_t cpustats_lock = ZBX_MUTEX_NULL;
static kstat_ctl_t *kc = NULL;
static kid_t kc_id = 0;
static kstat_t *(*ksp)[] = NULL; /* array of pointers to "cpu_stat" elements in kstat chain */
static int refresh_kstat(ZBX_CPUS_STAT_DATA *pcpus)
{
static int cpu_over_count_prev = 0;
int cpu_over_count = 0, inserted;
kid_t id;
kstat_t *k;
zabbix_log(LOG_LEVEL_DEBUG, "In %s()", __func__);
for (int i = 0; i < pcpus->count; i++)
(*ksp)[i] = NULL;
/* kstat_chain_update() can return: */
/* - -1 (error), */
/* - a new kstat chain ID (chain successfully updated), */
/* - 0 (kstat chain was up-to-date). We ignore this case to make refresh_kstat() */
/* usable for first-time initialization as the kstat chain is up-to-date after */
/* kstat_open(). */
if (-1 == (id = kstat_chain_update(kc)))
{