Here is the question, I got a thread which is assigned to certain cpu core. In that thread I would like to create another thread which should on non-isolated cpus (not on isolated cpu in that it is created).
std::thread th2;
std::thread th1([&] () {
th2 = std::thread([&] () {
//do something;
});
});
cpu_set_t cpu_set;
CPU_ZERO(&cpu_set);
CPU_SET(core, &cpu_set); // lets say 2
pthread_setaffinity_np(th1.native_handle(), sizeof(cpu_set_t), &cpu_set);
th2.join();
th1.join();
that causes unintended context switching is there any way to say internal thread get cpu from OS again (without explicit cpu affinity) ?
Aucun commentaire:
Enregistrer un commentaire