Advertisement
tobotras

Untitled

Aug 21st, 2014
286
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.44 KB | None | 0 0
  1.  long num_processor_configured = sysconf (_SC_NPROCESSORS_CONF); /* list the number of processors configured */
  2.  long num_processor_available;
  3.  cpu_set_t mask;
  4.  
  5.   if (sched_getaffinity(0, sizeof(cpu_set_t), &mask) == 0) {
  6.     num_processor_available = CPU_COUNT(&mask);
  7.   } else {
  8.     num_processor_available = sysconf(_SC_NPROCESSORS_ONLN);
  9.   }
  10.  
  11.   printf("CPUs: %ld configured, %ld online\n", num_processor_configured, num_processor_available);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement