10-13-2010 11:41 AM
Hi GUys,
I was wondering if there is a way to make better use of the computer processor by multiple threads? Example, if there are two subvi's 1 and 2 running in parallel or just two parallel loops in main, can we get them to run as separate threads? It should appear in the task manager of Windows as a separate processing that is running. LabVIEW.exe is just runs as one thread right? making it slower? Please help me out. THanks!
VeeJay
10-13-2010 11:50 AM
LabVIEW will automatically run the code in separate threads. It is very good about running things in parallel on multiple threads for you. You don't really need to do anything special to make this happen. If you have two parallel loops LabVIEW will run them on separate threads. In addition, it will use all of the CPU cores that you have.
10-13-2010 12:07 PM
Thank you mark!I have 2 subvi's one running at 100ms and the other at 250ms. The one with 250ms is used to count pulses from an encoder to obtain frequency and then speed. What I see is that when I run the program and switch between tabs on my front panel, I see a spike in the frequency value. It is physically non existent but LabVIEW reports it on the graph. This is true when I switch tabs and look at another program that is running. Basically, LabVIEW.exe uses 99% of the system resource. Now, does this mean I need a better computer to run LabVIEW 2009 or should some tweak in the program help me achieve better performance without lags on the screen while switching. Thanks!
VJ
10-13-2010 12:10 PM
@VeeJay wrote:
LabVIEW.exe is just runs as one thread right?
No, not right. LabVIEW.exe is multithreaded (you can enable in Task Manager column which will show number of threads).
In general, if you have multiple while loops, they will be executed in different threads. Just create simple VI with two empty while loops without any delays inside, and you will see that both cores occupied (if you have Dual Core CPU).
Remember, that UI thread is single. It means, if you have VI with "User Interface" preferred execution system or DLL calls which are not thread safe, or property nodes, then such cycles will be executed in UI thread or will be continously switched between threads - therefore performance penalties may occur.
AFAIK by default for each execution system 4 threads reserved (can be increased up to 😎
Andrey.