- Bind the invoke thread to a CPU core which id is p
{
cpu_set_t mask;
__CPU_ZERO(&mask);
__CPU_SET(p, &mask);
sched_setaffinity(0, sizeof(mask), &mask);
}
- Bind thread which id is tid to a CPU core p
{
cpu_set_t mask;
__CPU_ZERO(&mask);
__CPU_SET(p, &mask);
sched_setaffinity(tid, sizeof(mask), &mask);
}
Reference
No comments:
Post a Comment