LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

help:relation between subvi and thread

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. 

 

 

0 Kudos
Message 1 of 7
(4,022 Views)

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).

0 Kudos
Message 2 of 7
(4,017 Views)

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

0 Kudos
Message 3 of 7
(4,016 Views)

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.

 

0 Kudos
Message 4 of 7
(4,001 Views)
You just need to run the subVI in a seperate loop of its own. When the subVI is done, it can use a notifier mechanism to let the main VI know that it has finished execution. Have a look at the Master/Slave Design Pattern (File -> New..) to get an idea of how to use the notifier mechanism in LabVIEW.
Adnan Zafar
Certified LabVIEW Architect
Coleman Technologies
0 Kudos
Message 5 of 7
(3,990 Views)

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.

0 Kudos
Message 6 of 7
(3,974 Views)

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.

0 Kudos
Message 7 of 7
(3,967 Views)