I’ve word a bit with parallel processing in college and now I’m trying to get better at it. I can write code that can run in parallel and then start up threads, but after that I loose control over what the threads do. I would like to know how I can control the threads to things like for example bind a specific thread to a specific processor core.
I am mostly interested in c++ but I’ve done some coding of this in Java so those answers are also welcome.
I’m answering in Java perspective: That’s not possible. The best what you can control is the thread priority. To force Java to run on certain CPU/core, you have to do it in a platform specific way. In Windows for example, you can do that in the task manager by locating the process in the Processes tab, rightclicking the process in question (usually
java.exe), choosing Set Affinity and tick the CPU’s/cores.As you might guess, this indeed globally sets the affinity, not on basis of threads you create in Java.