I think the keyword you are looking for is "affinity". The call will be different on different OSs. Here is an example stackoverflow thread. <div><br></div><div><a href="http://stackoverflow.com/questions/1407786/how-to-set-cpu-affinity-of-a-particular-pthread">http://stackoverflow.com/questions/1407786/how-to-set-cpu-affinity-of-a-particular-pthread</a></div>
<div><br></div><div>Jeff<span></span><br><div><br></div><div><br>On Saturday, December 21, 2013, Florian Dietz wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div bgcolor="#FFFFFF" text="#000000">
The function ccl<big>::rdtsc can be used for counting cpu cycles,
but it returns results depending on the current cpu the program is
running on, which can be a problem for multithreaded applications.</big><br>
<br>
<big>Is there a way to get consistent values from the same cpu, so
that one can measure how many cpu cycles a given function took to
execute?</big><br>
<br>
<big>Alternatively, if this is not possible, would it be possible
(and sensible) to restrict a process to only a single cpu, to
avoid this problem?</big><br>
</div>
</blockquote></div></div>