How to start different threads on different cores?

Possible duplicate:
How to set the proximity of a processor to a specific pthread?

I am writing a C ++ program using the g ++ compiler in Ubuntu. I have 4 threads in my program and 4 cores on my processor. I want to be sure that each thread will be running on a different core. I am rarely familiar with pthread.

+8
c ++ multithreading pthreads
source share
2 answers
+5
source share

Do not do this. Let the system plan the flows. If you attach threads to individual cores, you are simply restricting the scheduler. When your application is the only consuming processor, the scheduler will naturally schedule each thread on a separate core.

+14
source share

All Articles