点击(此处)折叠或打开

  1. #include<stdio.h>
  2. #include<unistd.h>

  3. int main()
  4. {
  5. int cpu_num;
  6. cpu_num = sysconf(_SC_NPROCESSORS_CONF);
  7. printf("_SC_NPROCESSORS_CONF=%d\n",cpu_num);

  8. cpu_num = sysconf(_SC_NPROCESSORS_ONLN);
  9. printf("_SC_NPROCESSORS_ONLN=%d\n",cpu_num);

  10. return 0;
  11. }
  12. /*
  13. * - _SC_NPROCESSORS_CONF
  14. * The number of processors configured.
  15. *
  16. * - _SC_NPROCESSORS_ONLN
  17. * The number of processors currently online (available).
  18. */
/* 
* - _SC_NPROCESSORS_CONF
*       The number of processors configured.

* - _SC_NPROCESSORS_ONLN
*       The number of processors currently online (available).
*/ 
#include
#include

int main()
{
int cpu_num;
cpu_num = sysconf(_SC_NPROCESSORS_CONF);
printf("_SC_NPROCESSORS_CONF=%d\n",cpu_num);

cpu_num = sysconf(_SC_NPROCESSORS_ONLN);
printf("_SC_NPROCESSORS_ONLN=%d\n",cpu_num);

return 0;
}

12-17 08:59