07-04-2009 12:42 AM
In general, when a vi call a subvi, this subvi don't display front panel, is there any new thread is created?
For run a subvi, does that mean a new thread will be created with this subvi?
If i want to create a new thread when starting a subvi from main vi, how should i do?
please help me about these questons. I am not clear about thread in labview.
Thank you very much.
07-04-2009
01:24 AM
- last edited on
05-20-2024
07:19 PM
by
Content Cleaner
The details of thread allocation is discussed here.
Thread management is transparent in LabVIEW, even a single VI can use multiple threads. (see e.g.: this article).
Also note that
"... Advanced users can adjust some of the thread allocation settings by running vi.lib\Utility\sysinfo.llb\threadconfig.vi."
What exactly is your concern? Why do you think you need to worry about threads? Is there anything that you think is not handled correctly in your application?
You could assign the subVI to a different execution system (VI properties...execution).
07-04-2009 01:24 AM
It is not clear to me what you want to do.
In general you write your code and Labview executes it, the best way it can, by using multiple cores of CPU.
You don't have to do anything. Just wire in parallel. Labview will do rest.
If you need to set a subvi to a higher priority use VI Proterties>> Execution >> Priority
07-04-2009 06:23 AM
hi, altenbach and Pnt
Thank your answer firstly.
My design like that: a main vi, used to start series test items
one by one. After a test vi start, i hope it can run without dependency
with main vi, so it can be put into background when main vi handle user
operation. When test vi finish, it can notify main vi.
I am not sure about it. so I try to understand relation between subvi and
thread.
07-04-2009 08:12 AM
07-04-2009
11:10 AM
- last edited on
05-20-2024
07:20 PM
by
Content Cleaner
mmm2006 wrote:
My design like that: a main vi, used to start series test items
one by one. After a test vi start, i hope it can run without dependency
with main vi, so it can be put into background when main vi handle user
operation. When test vi finish, it can notify main vi.
I am not sure about it. so I try to understand relation between subvi and
thread.
OK, this really has nothing to do with threads. A subVI will run in parallel if there is no data dependency that forces sequential execution. All you probably need to do is create a VI reference to the subVI and run it using the Run VI Method.
Make sure you set "wait until done" to false, so the main program will continue. This is the most general method, and you can have several subVIs running at the same time, each started and stopped independently.
It seems that you actually want to run the VIs one-by-one, so the way I understand it, the next subVI should wait intil the current subVI has finished. Similar to what Adnan suggested, you would simply use two parallel loops linked via a queue. The UI loop is always ready to handle user interaction. The second loop would run the various VIs, or simply wait until a new subVI needs to be run.
07-04-2009 11:56 AM
hi, altenbach and Adnan Zafar, If i create a vi reference to start subvi, Can I save this vi reference to close the subvi when user want to cancel this test
item? is that possible to implement?
For consumer and producer pattern, I think it is a good for me. user's action can be sent to consumer by queue,for consumer's notifier to producer,should
I use another queue,right? I don't want to make very complicated in comunication between main vi and test items. So I think it is better that main vi decide
which and when to start, display or cancel a test. Can you comment my idea about this? After a subvi finished, how can it return a flag to notify main vi? I
had thought adopting a global variant and checking it in main vi, but it is not a good. Can you give me any advice about this?
Thank your help very much.