LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to set processor affinity programmatically

Hello,

 

Could anybody please know, How to set the processor affinity programmatically.

 

Thanks,

0 Kudos
Message 1 of 6
(4,857 Views)

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

Norbert
----------------------------------------------------------------------------------------------------
CEO: What exactly is stopping us from doing this?
Expert: Geometry
Marketing Manager: Just ignore it.
0 Kudos
Message 2 of 6
(4,855 Views)

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,

 

 

0 Kudos
Message 3 of 6
(4,852 Views)

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

Norbert
----------------------------------------------------------------------------------------------------
CEO: What exactly is stopping us from doing this?
Expert: Geometry
Marketing Manager: Just ignore it.
Message 4 of 6
(4,847 Views)

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,

0 Kudos
Message 5 of 6
(4,845 Views)

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:

 

http://www.howtogeek.com/howto/windows-vista/start-an-application-assigned-to-a-specific-cpu-in-wind... 

-Barrett
CLD
0 Kudos
Message 6 of 6
(4,840 Views)