How to use sched_getaffinity and sched_setaffinity in Linux from C?
To use sched_setaffinity to make the current process run on core 7 you do this: cpu_set_t my_set; /* Define your cpu_set bit mask. */ CPU_ZERO(&my_set); /* Initialize it all to 0, i.e. no CPUs selected. */ CPU_SET(7, &my_set); /* set the bit that represents core 7. */ sched_setaffinity(0, sizeof(cpu_set_t), &my_set); /* Set affinity of tihs … Read more