I'm going to write a program where one thread is busy on data aquisition from PCI card, and other threads are doing all other things. Now, I would like to assign that aquisition thread to one CPU, and other threads to the other CPU (It may be really two CPU's, or just hyper-threaded). How do I choose CPU for thread programatically in e.g. C++? Is it possible, or will it work as assigning CPU according to how much one is busy, so the other will be then assigned?
thank you very much for answering to this question
I've done some testing via Managed C# code with Thread Affinity and noticed a performance decline when tasking a single HT/Multi-core processor by thread as opposed to usingThreadPool Queue.
Im far (quite literally in outter space) from being an expert in this area but heck I might as well throw my comments out and see what other have to say.. I know I have quite a bit of learning to do anyway..
Kevin (Intel ASP.Net Web dude...)
From your description "single HT/Multi-core processor" Windows will percieve 4 processors when in fact you have 2 cores, each with two HT thread capability. What you want is one core dedicated to your applicationi (both HT threads on that core reserved but only one in use).
I think your best results (for the priorityapplication thread) would be to isolate each core. With "processors" 0 and 1 on one core and "processors" 2 and 3 on the second core. Using the Task Manager | Processes tab | right-click on each ofnot-your-application processies and set affinity to restrict processing to the 1st core (cpu0 and cpu1). Then modify your application to set affinity to CPU2 (2nd core).
If you start any applications after initialization (Task Manager setting of affinity) then you will have to reset affinity on the new processes.
Experiment running this way and check results.