Page 1 of 1

selecting a CPU for a thread/process

Posted: Thu Jul 19, 2012 8:42 am
by alokdube
Hi,

Is it possible to bind a cpu to a thread/process?
More like Bind_thread(cpu id, thread name etc)

I have seen this API some where in POSIX way back 2003/2004
http://lists.freebsd.org/pipermail/free ... 29012.html
However most of these too bind it to a "pseduo CPU" which is actually an OS abstraction, not a real cpu core.

Re: selecting a CPU for a thread/process

Posted: Fri Jul 20, 2012 1:12 am
by ozzie
+1

Could be very useful, provided it's also possible to determine which processor the main thread is running on.

Re: selecting a CPU for a thread/process

Posted: Fri Jul 20, 2012 5:16 am
by IdeasVacuum
Intel have a lot of stuff on this (surprise surprise) but their website is very hard work.

Re: selecting a CPU for a thread/process

Posted: Fri Jul 20, 2012 11:42 am
by luis
On Windows maybe SetThreadAffinityMask / SetProcessAffinityMask can do what you ask.

Re: selecting a CPU for a thread/process

Posted: Fri Jul 20, 2012 6:35 pm
by freak
Why do you want to do this?

Re: selecting a CPU for a thread/process

Posted: Fri Jul 20, 2012 7:37 pm
by xorc1zt
http://en.wikipedia.org/wiki/Affinity_mask

intel and amd advice to use the openmp lib.

Re: selecting a CPU for a thread/process

Posted: Sat Jul 21, 2012 2:01 am
by ozzie
freak wrote:Why do you want to do this?
In my app (Show Cue System) I have a control thread that primarily monitors cues being played, and triggers auto-start cues when required. There is also a 'blending' thread for cross-fading images, and a thread for buffering files. There are also some other threads for lesser used activities (such as for handling network activity), but probably the thread that has the most visual impact is the blending thread. I do usually get a smooth cross-fades even now, but I would expect that cross-fades would be consistently smooth if I could assign this thread to a different processor to that running the control thread or the buffering thread (assuming the PC has multiple processors).