Reputation: 1414
How can I force an application I'm writing to only use a single processor core?
Upvotes: 1
Views: 240
Reputation: 12116
There is a Linux system call specifically for this purpose called sched_setaffinity
For example, to run on CPU 0:
#include <sched.h>
int main(void)
{
cpu_set_t mask;
CPU_ZERO(&mask);
CPU_SET(0, &mask);
result = sched_setaffinity(0, sizeof(mask), &mask);
return 0;
}
Upvotes: 7