hilli
hilli

Reputation: 11

How can I ask the OS to run each thread on another core?-Linux OS

I am trying to run a multiple threads program on a 4 core processor, and I want each thread to run on a different core.

How can I do that? Because right now I see that they all running on the same core.

(I'm using Linux OS and my code was wrriten on c.)

Upvotes: 1

Views: 601

Answers (1)

Rich Homolka
Rich Homolka

Reputation: 1955

Process schedulers make processes have an affinity towards a specific CPU. You've already loaded a bunch of stuff into cache, you may as well keep using this 'hot' cache.

You may be getting all the threads on this same core, since you already have the program loaded here.

I did find this: pthread_setaffinity_np. It seems clumsy, but i hope it's of some use.

Upvotes: 4

Related Questions