jmasterx
jmasterx

Reputation: 54133

creating thread on another core? (WinAPI)

I was wondering if there was a way to run a thread on a seperate core instead of just a thread on that core? Thanks

Upvotes: 0

Views: 466

Answers (1)

Alexander Gessler
Alexander Gessler

Reputation: 46637

If you create a thread, you have by default no control on which core it will run. The operation system's scheduling algorithm takes care of that, and is pretty good at its job. However, you can use the SetThreadAffinity WinAPI to specify the logical cores a thread is allowed to run on.

Don't do that unless you have very good reasons. Quoting MSDN:

Setting an affinity mask for a process or thread can result in threads receiving less processor time, as the system is restricted from running the threads on certain processors. In most cases, it is better to let the system select an available processor.

Upvotes: 4

Related Questions