LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

calling a vi in multiple instances

Hi All,

Is Reentrant VI the Best option for calling a subvi in multiple instances?
Can I use semaphore.?
Is there any other ways proven best.

Thanks,
Davidson
0 Kudos
Message 1 of 5
(3,143 Views)
I'm not sure what you mean by "multiple instances", but this is the basic deal:

Reentrant VI are routines that are when placed on a block diagram, each instance of the VI runs in its own memory space. The result is that multiple copies of the VI can be executing simultaneously, but the memory usage goes up. Also some types of code (like functional globals) stop working when they are made reentrant.

In terms of semaphores, they are a signaling mechanism, so again I'm not exactly sure what you are trying to accomplish.

Mike...

Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion

"... after all, He's not a tame lion..."

For help with grief and grieving.
Message 2 of 5
(3,142 Views)
Hi Mike,
 
I have a subVI (reentrant)  which is being used 20 times in the Main VI.
All the subVIs run in parallel with independent data input and output.
Each use of the subVI in my main VI is what i mentioned as "muliple Instances"
 
As You mentioned about the memory usage, this VI would take 20 copies of the subVI everytime.
I was not sure whether this (reentrant) aproach right .
 
Regarding semaphore, i'm not yet tried. I thought of possibility to implement without reentrant VI.
Can You get me..?
 
Thanks,
Davidson
 
0 Kudos
Message 3 of 5
(3,123 Views)
"I have a subVI (reentrant)  which is being used 20 times in the Main VI.
All the subVIs run in parallel with independent data input and output."
 
This is exactly where multiple copies of reentrant VI's are most useful. Your approach is fine. Depending on what your code is doing, if you went with a single copy of a non-reentrant VI you might see the performance of your code drop significantly.
PaulG.
Retired
0 Kudos
Message 4 of 5
(3,114 Views)


davidson.d wrote:
I have a subVI (reentrant)  which is being used 20 times in the Main VI.
All the subVIs run in parallel with independent data input and output.
Each use of the subVI in my main VI is what i mentioned as "muliple Instances"
 
As You mentioned about the memory usage, this VI would take 20 copies of the subVI everytime.
I was not sure whether this (reentrant) aproach right .
 
Regarding semaphore, i'm not yet tried. I thought of possibility to implement without reentrant VI.
Can You get me..?

It really depends on what the subVI does. Does each one run for extended periods and do you really need to run all of them in parallel? (after all, you most likely don't have 20 CPUs).
 
If you don't make it re-entrant, only one instance can run at the same time and other instances will wait automatically until they get their turn. No semaphores needed.
 
If typically only a few run in parallel, you can configure it for "shared clones", striking a possibly better balance between memory use and parallelism.
 
It would help if you could be more specific on how your main program is layed out and what the subVI actually does. The best solution strongly depends on this information.
Message 5 of 5
(3,088 Views)