LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

SubVI being used twice within a VI

Solved!
Go to solution

As I am always learning new things in Labview, I have a question.

 

Can there be a rece condition if I use the same SubVI twice within the same VI? See attached.

Download All
0 Kudos
Message 1 of 6
(2,709 Views)

if it is done at the very same momment (race condition), otherwise you can use the same vi at different processes.

0 Kudos
Message 2 of 6
(2,705 Views)

So, if I understand you correctly, the VI can have two instances running at the same time?

0 Kudos
Message 3 of 6
(2,702 Views)

hm.. I would say you're speaking about reantrancy --> VI properties --> Category "Execution"

 

The point is that the normal behavior let's your second VI execute when the execution of the first instance is done... The question is how time critical your application is and: are you working in a parallel structure? When everything is serial and working with the dataflow the instances of your VI will never be executed at the same time...

 

Don't know.. does that solve your question?!?

0 Kudos
Message 4 of 6
(2,690 Views)
Solution
Accepted by topic author Eric1977

By default, a VI can only have 1 instance at a time.  This means that if a VI is running and another VI calls it, the new calling VI must wait until the subVI completes in order to run.  This is desired if you are retaining state information (Action Engines or Functional Global Variables).  If you are not maintaining state, then it can probably be safe to set the VI to be reentrant, which means that there can be multiple instances of the VI in memory, each instance will have its own block in memory.  This uses more memory.  For the most part, subVIs are going to run fast enough that you don't need to worry about the reentrancy as the waiting to run will be really short.

 

Quickly looking at your code, I wouldn't worry about the reentrancy since your subVI is going to execute quickly.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 5 of 6
(2,688 Views)

Thank you, crossrulz.

0 Kudos
Message 6 of 6
(2,679 Views)