Advertisement
Guest User

Untitled

a guest
Aug 30th, 2016
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.67 KB | None | 0 0
  1. Set:-
  2.  
  3. cpu_set_t mask;
  4. CPU_ZERO(&mask);
  5. pid_t pid = gettid(); // Thread. For pid, use getpid()
  6.  
  7. CPU_SET(1, &mask);
  8. if(sched_setaffinity(pid, sizeof(mask), &mask) == -1) {
  9. LOGE("set affinity failed, cpu: 1");
  10. }
  11.  
  12. //int syscallres = syscall(__NR_sched_setaffinity, pid, sizeof(mask), &mask);
  13. //if (syscallres)
  14. //{
  15. // err = errno;
  16. // LOGE("Error in the syscall setaffinity: mask=%d=0x%x err=%d=0x%x", mask, mask, err, err);
  17. //}
  18.  
  19. Get :-
  20.  
  21. cpu_set_t get;
  22. CPU_ZERO(&get);
  23. if (sched_getaffinity(0, sizeof(get), &get) == -1)
  24. {
  25. LOGE("warning: cound not get thread affinity, continuing...");
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement