1#include <sys/sysinfo.h> 2#include <unistd.h> 3 4int get_nprocs_conf() 5{ 6 return sysconf(_SC_NPROCESSORS_CONF); 7} 8 9int get_nprocs() 10{ 11 return sysconf(_SC_NPROCESSORS_ONLN); 12} 13 14long get_phys_pages() 15{ 16 return sysconf(_SC_PHYS_PAGES); 17} 18 19long get_avphys_pages() 20{ 21 return sysconf(_SC_AVPHYS_PAGES); 22} 23