How to get the number of CPUs in Linux using C?
#include <stdio.h>
#include <sys/sysinfo.h>
int main(int argc, char *argv[])
{
printf("This system has %d processors configured and "
"%d processors available.\n",
get_nprocs_conf(), get_nprocs());
return 0;
}
https://linux.die.net/man/3/get_nprocs
#include <unistd.h>
long number_of_processors = sysconf(_SC_NPROCESSORS_ONLN);