Affect of sched_setaffinnnity() on new threads

  affinity, c++, linux, multithreading

Does sched_setaffinnnity() that is called from a "main" process, affects the running core on which new threads are created from this running process?

From what see, all the threads that are created after calling sched_setaffinnnity() are always
created in the same core that the "main" process was set to run, but I wonder if that something I can count on to happen every time the program is executed.

In the following pseudo-code, is it guaranteed that threadA, threadB and threadC will always be running on the same core:

int main()
{
   sched_setaffinnnity(...);
   threadA = std::thread();
   threadB = std::thread();
   threadC = std::thread();
}

Source: Windows Questions C++

LEAVE A COMMENT