https://linux.die.net/man/3/get_nprocs
#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;
}
#include <sys/sysinfo.h>
int get_nprocs(void); //获取可用的cpu数
int get_nprocs_conf(void); //获取操作系统配置的cpu数
网友评论