selecting a CPU for a thread/process

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
alokdube
Enthusiast
Enthusiast
Posts: 148
Joined: Fri Nov 02, 2007 10:55 am
Location: India
Contact:

selecting a CPU for a thread/process

Post 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.
ozzie
Enthusiast
Enthusiast
Posts: 443
Joined: Sun Apr 06, 2008 12:54 pm
Location: Brisbane, Qld, Australia
Contact:

Re: selecting a CPU for a thread/process

Post by ozzie »

+1

Could be very useful, provided it's also possible to determine which processor the main thread is running on.
IdeasVacuum
Always Here
Always Here
Posts: 6426
Joined: Fri Oct 23, 2009 2:33 am
Location: Wales, UK
Contact:

Re: selecting a CPU for a thread/process

Post by IdeasVacuum »

Intel have a lot of stuff on this (surprise surprise) but their website is very hard work.
IdeasVacuum
If it sounds simple, you have not grasped the complexity.
User avatar
luis
Addict
Addict
Posts: 3893
Joined: Wed Aug 31, 2005 11:09 pm
Location: Italy

Re: selecting a CPU for a thread/process

Post by luis »

On Windows maybe SetThreadAffinityMask / SetProcessAffinityMask can do what you ask.
"Have you tried turning it off and on again ?"
A little PureBasic review
freak
PureBasic Team
PureBasic Team
Posts: 5940
Joined: Fri Apr 25, 2003 5:21 pm
Location: Germany

Re: selecting a CPU for a thread/process

Post by freak »

Why do you want to do this?
quidquid Latine dictum sit altum videtur
xorc1zt
Enthusiast
Enthusiast
Posts: 276
Joined: Sat Jul 09, 2011 7:57 am

Re: selecting a CPU for a thread/process

Post by xorc1zt »

http://en.wikipedia.org/wiki/Affinity_mask

intel and amd advice to use the openmp lib.
ozzie
Enthusiast
Enthusiast
Posts: 443
Joined: Sun Apr 06, 2008 12:54 pm
Location: Brisbane, Qld, Australia
Contact:

Re: selecting a CPU for a thread/process

Post 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).
Post Reply