I read some articles about this problem. The case seems not easy. I want to create two different thread in two core. the articles that I read were too complicated. I even couldn't create a simple thread based on those articles. at the other hand I need to understand how many cores a computer have to make available as a choice for using both core or just create threads on one core. I want to do them on windows. Any help would highly welcome
P.S: I am not that pro on C++. So please if it is possible guide me with easier ways.
Though it's generally a lousy idea (the thread scheduler usually does a better job on its own), the basic idea would be:
Note that the
1<<0
and1<<1
could just as easily be written as1
and2
respectively -- I was just trying to make explicit the fact that each bit position represents a processor.For posix, check out
pthread_getaffinity_np
andpthread_setaffinity_np