Originally Posted by
iMalc
If I had to guess, I'd say that Linux is forcing any extra threads you create to run on the same core, like there's some affinity mask set on the application. Any way you can check that?
I am trying to use linux system call to determine that, but so far, all I've got is a compile error:
Code:
pid_t pid = getpid();
cpu_set_t affinity;
sched_getaffinity(pid, sizeof(affinity), &affinity);
unsigned long long tmp;
for (int i = 0; i < 64; i++)
if (CPU_ISSET(i+1, affinity))
tmp |= (i+1);
std::cout << "Hello from thread scheduled on " << std::hex << tmp << "!\n";
error: base operand of '->' has non-pointer type 'cpu_set_t'
EDIT: Found another way:
[peklof@sky4 ~]$ ./foo &
[1] 23142
[peklof@sky4 ~]$ taskset -p 23142
pid 23142's current affinity mask: ffffff
So no, it is set to execute on all cpus. Unless this changes from thread to thread.