Linux has many threads and processes executing across (lets say 2) CPU cores. I would like my single-threaded C/C++ application to be the only thread on CPU0. How would I "move" all the other threads to use CPU1?
I know I can use the Linux CPU scheduling functions to set affinity for a thread:
int sched_setaffinity(pid_t pid,size_t cpusetsize,cpu_set_t *mask);
but how I can push all the other threads on to CPU1? Is there a relatively simple way of doing this?
Would I have to get a list of all the pids, iterate through setting them all to CPU1 and then set my application thread to CPU0?