LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Functional global set as reentrant vi in CLD sample?

In the CLD atm sample question attached. It set its functional global as a reentrant vi...:womansurprised:

 

Now let me get this right :womanhappy:, a non reentrant vi, no matter how many times it's called, stores its data into one location. So a functional global should be a nonreentrant vi so the functional global can SET the same data in the same place, and GET the same data in the same place.

 

Whereas a nonreentrant vi creates clones everytime it is called, and each clone stores a different set of data in a different place. So a functional global should not be a reentrant vi because it cannot retrieve the same copy of data; there are many different data sets stored in different places, the functional global would not know which data set to retrieve.

 

But how come this CLD sample set its functional global as reentrant vi and it works??ScreenHunter_01 Apr. 15 08.29.gif?

 

 

Message 1 of 35
(5,684 Views)

Reentrant execution + Preallocate clones is my guess. 😉

reentrant.png

 

/Y

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
Message 2 of 35
(5,661 Views)

I agree with sunflower that pre-allocating instances should not explain the behaviour.

 

Pre-allocating clones should permit to store the shift register values for each subsequent calls to each instance, but with an FGV, the aim is to share datas between several instances. In this way, i don't understand why this example works, because of reentrant option, each instance should be independent and not sharing the same memory allocation for shift registers.

 

Am I mistaking?

Olivier L. | Certified LabVIEW Developer


Message 3 of 35
(5,644 Views)

Well, here why it works:

The setting is share clones between instances, so if not more than one instance of this VI is called simultaneously, they will share the dataspace (same behavior as non-reentrant VIs). Still, if using this VI in a way where the usage is not sequential, you will run into issue because the calls do not share the data. This is a no-go for a FGV, so the example is nonsense.

 

So please everyone reading this:

The setting for the FGV in this example is stupid and should never be configured like this! FGVs have to be non-reentrant in order to work properly.

 

hope this helps,

Norbert

Norbert
----------------------------------------------------------------------------------------------------
CEO: What exactly is stopping us from doing this?
Expert: Geometry
Marketing Manager: Just ignore it.
Message 4 of 35
(5,634 Views)

Norbert B a écrit :
The setting is share clones between instances, so if not more than one instance of this VI is called simultaneously, they will share the dataspace (same behavior as non-reentrant VIs). Still, if using this VI in a way where the usage is not sequential, you will run into issue because the calls do not share the data. This is a no-go for a FGV, so the example is nonsense.

Is there a KB on ni.com about both possible configurations for a reentrant VI ?

Message 5 of 35
(5,626 Views)

Thanks Norbert,

 

I totally agree with the non-sense.

 

But why is that implemented in an example in CLD e-kit? and it's obviously a wanted configuration well documented on block diagram as shown on printscreen.

Olivier L. | Certified LabVIEW Developer


Message 6 of 35
(5,612 Views)

You might want to take a look into this KB.

 

@Olivier: I have no idea, why the example exam does include this....

 

hope this helps,

Norbert

Norbert
----------------------------------------------------------------------------------------------------
CEO: What exactly is stopping us from doing this?
Expert: Geometry
Marketing Manager: Just ignore it.
Message 7 of 35
(5,617 Views)

In your VI code "Shared clone is selected"

Below are past from the LV manual --

 

"Memory Usage - Only allocates clone VIs for the maximum number of simultaneous calls to the reentrant VI. Decreases memory usage..."

"Execution Speed - Creates clone VIs on demand. Slightly decreases execution speed and speed may vary per call.."

 

...and Preallocate is versa of above.

 

Yes the only reason to use Reentrant in any LV example is to keep separate copies in memory. This author uses the reentrant VI to track 3 different transaction in his example (looks like an banking ATM, I have not run it as yet). The author reentrant is for "deposit", "withdrawal" and "pin entry". Ctrl+F, the VI is used in 4 instances, one of them is to Get current action, the other 3 are Set.

 

IMHO, the example is overblown. Wonder how long it took the author to create it?

Message 8 of 35
(5,593 Views)

@richjoh wrote:

In your VI code "Shared clone is selected"

Below are past from the LV manual --

 

"Memory Usage - Only allocates clone VIs for the maximum number of simultaneous calls to the reentrant VI. Decreases memory usage..."

"Execution Speed - Creates clone VIs on demand. Slightly decreases execution speed and speed may vary per call.."

 

...and Preallocate is versa of above.

 

Yes the only reason to use Reentrant in any LV example is to keep separate copies in memory. This author uses the reentrant VI to track 3 different transaction in his example (looks like an banking ATM, I have not run it as yet). The author reentrant is for "deposit", "withdrawal" and "pin entry". Ctrl+F, the VI is used in 4 instances, one of them is to Get current action, the other 3 are Set.

 

IMHO, the example is overblown. Wonder how long it took the author to create it?


The reason it works is all access is sequential.

 

Overblown, yes. Reminds of the kid trying to show-off by climbing over the fence to pose next to the lion's cage. It will bite them eventually.

 

Keep It Simple Sir has clearly bee violated.

 

I will watch for someone who can explain WHY that was a good decision unless they felt there would 500 of these ATM GUIs running in parallel.

 

Ben

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
Message 9 of 35
(5,577 Views)

IMHO, here's one example why I comment above. See the attached pic, the author's code has coercion dots (I guess there are no points off for leaving coercion code). The code creates a bundle of references using Bundle VI, then the bundled wire is unbundle using Unbundle By Name. If he had used Bundle by Name with Unbundle by Name no need for coercion...Smiley Surprised. There's more of bad example but no need to go on an on here...

Message 10 of 35
(5,574 Views)