LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Make all subVIs reentrant

Is there an easy way to make subVIs reentrant if their calling VI is reentrant? I just realized I have a VI managing TCP/IP connections, and it's running in parallel but was not made reentrant. Inside it are a few subVIs that build the data packets to send. While it is not terribly difficult to manually change all subVIs, is there a way to make subVIs all reentrant also?

0 Kudos
Message 1 of 13
(6,512 Views)

Well, the VI class has both a Callees[] property and an IsReentrant property, so you can certainly write some simple VI server code which will do this recursively, but it will almost certainly be faster (and safer) to do this manually because you would have to be careful at where to stop and which VIs not to do this to.

 

You could probably do this more easily if you go over the hierarchy of files directly, but that depends on all your VIs being in one place with no other VIs being there.


___________________
Try to take over the world!
Message 2 of 13
(6,482 Views)

I agree with tst, you do NOT want to do this willy-nilly.  Having some automatic convert-to-reentrant gizmo would undoubtedly convert something to reentrant that you didn't want to.

 

Best to apply the old gray matter to it.

Steve Bird
Culverson Software - Elegant software that is a pleasure to use.
Culverson.com


LinkedIn

Blog for (mostly LabVIEW) programmers: Tips And Tricks

Message 3 of 13
(6,477 Views)

 


@tst wrote:

Well, the VI class has both a Callees[] property and an IsReentrant property, so you can certainly write some simple VI server code which will do this recursively, ...


And - display the VI names!  a quick checkbox array will give you control over which VIs to make re-enterant and which you would be better off  leaving aloneSmiley Wink

 

Of course TEST your auto-reenterant vi on a dummy project.  wouldn't want a bug to cause lots of new onesSmiley Very Happy

 


"Should be" isn't "Is" -Jay
Message 4 of 13
(6,460 Views)

Be aware that indiscriminately making a lot of code reentrant could also dramatically increase your memory use.  Note that there are several flavors of reentrant to address this very problem.  Read up on them in the LabVIEW help before proceeding.  I have seen a program halve its memory use due to fixing reentrancy problems.

Message 5 of 13
(6,405 Views)

Thanks for the tips, everyone. I will proceed manually, but sounds like it might be time to add something to the tools menu for this. I really like the checkbox idea, Jeff.

0 Kudos
Message 6 of 13
(6,395 Views)

sounds like it might be time to add something to the tools menu for this.

 

I don't see why. In your case, you said:

I have a VI managing TCP/IP connections, and it's running in parallel but was not made reentrant. Inside it are a few subVIs that build the data packets to send.

 

The two features of re-entrancy are 1) separate data spaces for local variables for each instance, and 2) the ability to interrupt execution of instance A and proceed with instance B, then return to instance A (which requires #1).

 

I've done work managing connections, and my scenario requires one and only one VI being reentrant.  It's hard for me to picture a need for enough different VIs being reentrant to justify another tool.

 

Just my 2 cents.

Steve Bird
Culverson Software - Elegant software that is a pleasure to use.
Culverson.com


LinkedIn

Blog for (mostly LabVIEW) programmers: Tips And Tricks

Message 7 of 13
(6,384 Views)

Actually, I have already taken your advice and just made the top level VI reentrant. However, it shouldn't be too difficult to build a tool for this and may be nice to have in the future, even though I won't be using it in this case.

 

That said, does anyone know why the attached VI errors out where I have circled it in red on the BD? This is more of a recursive call issue then an issue that I have asked about in the original post.

0 Kudos
Message 8 of 13
(6,366 Views)

@for(imstuck) wrote:

 

That said, does anyone know why the attached VI errors out where I have circled it in red on the BD? This is more of a recursive call issue then an issue that I have asked about in the original post.


I guess I have to leave the references open until it's all said and done. However, can someone explain why? Why does it need these unused references in subsequent recursive calls? Or is it using them. I have a feeling I'm just not understanding what's happening in the background.

0 Kudos
Message 9 of 13
(6,352 Views)

@Jeff Bohrer wrote:

 


@tst wrote:

Well, the VI class has both a Callees[] property and an IsReentrant property, so you can certainly write some simple VI server code which will do this recursively, ...


  

  

In 2010 I don't see the "Callees" property. I just see callers. I did find another VI that has it but the property node is a pinkish-red color

0 Kudos
Message 10 of 13
(6,343 Views)