LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How do uninitialized shift registers work in reentrant VI's

Solved!
Go to solution
If I am using what NI calls "Functional Global Variables" (see link) where you use an unitialized shift register in a "one shot" while loop,  what happens to the functionality of the shift register if the VI is reentrant?
 
 
 
0 Kudos
Message 1 of 4
(3,354 Views)
Solution
Accepted by topic author paulmw
I was tempted to say that they work as expected, but you have already said that you don't know what to expectSmiley Happy.

A reentrant VI is one that has its own dataspace.  That means that if I have two of them, they each have their own data and know nothing about each other.  This is great for VIs that need to save state for some reason.  Some examples of this are moving averages or some filters.  They need to know values from the last time they were called in order to calculate the answer for this time and they need to keep track of this answer for use in calculations next time they are called.  If these VIs had a single dataspace but were called in several places, their data from last run could be the data from the other call and therefore not be correct. 

This is where reentrancy comes in.  You merely make this VI reentrant and it saves state correctly because now each call has its own dataspace and therefore its own data.

Functional Globals work on the opposite principle.  You want to mix the data from one call location with the data from another.  You want to have it save state from this time and use that data reguardless of the caller the next time it is run.  You cannot make Functional Globals into reentrant VIs.

I hope that this helped.
Bob Young
Message 2 of 4
(3,346 Views)

I agree, uninitialized registers in a reentrant function makes no sense since there will not be a case where the function is recalled.  You just end up with an uninitialized variable.

Paul

Paul Falkenstein
Coleman Technologies Inc.
CLA, CPI, AIA-Vision
Labview 4.0- 2013, RT, Vision, FPGA
0 Kudos
Message 3 of 4
(3,342 Views)
Thanks guys,
I did some experimenting with this and they work as you said.  I kind of suspected this but I wanted to make sure.
 
FYI,
What I am doing is modifing some code that currently uses functional variables to keep track of a trasmission count (among other info) of messages that get put out on one of the serial comm ports.  Now the test station is going to try to run two UUT's in parallel on seperate com ports.  I am trying to maximize the execution so the VI modules (called from Teststand) run reentrantly.
 
My solution that I am attempting is to create a "manager" (based on functional global variables) that builds an array of "channels" that I can index per testsocket.  The manager wont be reentrant but the VI's that handle the protocol can be.
Again thanks,
Paul
0 Kudos
Message 4 of 4
(3,335 Views)