04-01-2010 08:18 AM
Hello,
Could anybody please know, How to set the processor affinity programmatically.
Thanks,
04-01-2010 08:24 AM
On Windows, you can go two different ways:
a) If you want to set the processor/core affinity of only a small part of your application: Use timed structures.
b) If you want to set the processor/core affinity for the whole LabVIEW.exe process, use the task manager and restrict it to the cores you want it to run on.
hope this helps,
Norbert
04-01-2010 08:31 AM
Norbert,
Thank you for your mail.
It has to set every time, when I start LabVIEW application. I do not want to set manually using task manager.
Even if I restart PC and start program then it has to run in desired processor.
Thanks,
04-01-2010 08:46 AM
There is no way that i am aware of to set LV to use a certain core(s) from the moment it is launched.....
But you can add a call to the Windows SDK API in your application to ensure the execution of the application on certain core(s) only. This would be the function SetProcessAffinityMask from the Kernel32.dll in the Windows/System32-folder.
(see this link for information)
To be honest, i'd expect a very comparable result from this approach to usage of timed structures with core-assignment.......
hope this helps,
Norbert
04-01-2010 08:52 AM
Norbert,
Thanks for the info.
I think, using .Net VIs, we can set, but I am not able to find correct way. If I find then I will let you know.
Thanks,
04-01-2010 09:01 AM
You can set affinity in windows when using the "start" command-line option. not 100% sure which windows versions support this, probably only vista and win7. XP does not.
here's a link: