user1524403
user1524403

Reputation:

Threading With Multiple Cores C++

I don't know how to thread in C++ and I would not just wan't to know that but is there a way i can force a thread onto a different core? Also how would I find out how many cores the user has?

Upvotes: 1

Views: 256

Answers (1)

arrowd
arrowd

Reputation: 34401

Binding thread to the arbitrary CPU is called setting affinity. It's platform-dependent operation.

For windows: SetProcessAffinityMask

For pthreads: pthread_attr_setaffinity_np(3) and pthread_setaffinity_np(3)

For Boost you can use native_handle() to get platform-specific thread handle to use them with functions above.

Upvotes: 4

Related Questions