daily pastebin goal
30%
SHARE
TWEET

Untitled

a guest Mar 13th, 2018 49 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <sys/types.h>
  2. #include <unistd.h>
  3. #include <stdio.h>
  4. #include <plpa.h>
  5.  
  6. int
  7. main()
  8. {
  9.   pid_t pid;
  10.   size_t cpusetsize;
  11.   plpa_cpu_set_t mask;
  12.  
  13.   pid = getpid();
  14.   cpusetsize = 8;
  15.  
  16.   if (plpa_sched_getaffinity(pid, cpusetsize, &mask) == -1)
  17.     perror("could not get cpu affinity");
  18.  
  19.   /* Clear bit mask */
  20.   PLPA_CPU_ZERO(&mask);
  21.   /* Set values in bit mask, e.g. processors 0,1,2 */
  22.   PLPA_CPU_SET(0, &mask);
  23.   PLPA_CPU_SET(1, &mask);
  24.   PLPA_CPU_SET(2, &mask);
  25.   /* Remove some values in bit mask, e.g. processors 0 and 2 */
  26.   PLPA_CPU_CLR(0, &mask);
  27.   PLPA_CPU_CLR(2, &mask);
  28.  
  29.   if (plpa_sched_setaffinity(pid, cpusetsize, &mask) == -1)
  30.     perror("could not set cpu affinity");
  31.  
  32.   return 0;
  33. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top