Skip to content

Instantly share code, notes, and snippets.

@raw-bin
Created January 29, 2018 13:57
Show Gist options
  • Save raw-bin/e93942f82fc6bab317e955662764c673 to your computer and use it in GitHub Desktop.
Save raw-bin/e93942f82fc6bab317e955662764c673 to your computer and use it in GitHub Desktop.
3 int set_affinity_to_cpu(int cpu)
1 {
2 cpu_set_t cpu_mask;
3 int status;
4
5 CPU_ZERO(&cpu_mask);
6 CPU_SET(cpu, &cpu_mask);
7
8 status = sched_setaffinity(0, sizeof(cpu_mask), &cpu_mask);
9 if (status)
10 return 1;
11 else
12 return 0;
13 }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment