LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Multi instance of function global

Why not ?

Although i have not tried it...

Message 11 of 25
(2,502 Views)
I believe that if you call them by reference with Option 8, you can ensure that each retains its own data space.
Message 12 of 25
(2,497 Views)

The whole idea of a functional global is that it is a place to hold data in single known place in memory that can only be accessed by one process at a time.  That helps prevent race conditions that can occur with other variables.  If it's reentrant, you don't know where the data is because you don't have control over how many copies that NI creates.

Message 13 of 25
(2,496 Views)
Ah, but if you set the reentrancy to preallocate memory for each clone, it will ensure distinct dataspace for each reference, and the reference will carry the specific instance through.
Message 14 of 25
(2,493 Views)

Jeff,

I think I see what you're getting at.  I'll agree that in the specific instance of using Open VI Reference with option 08 and using the Call By Reference Node that a reentrant functional global should work. 

Anyone else reading this thread just needs to understand that all calls to the reentrant functional global are by reference only and not by calling it directly as a subvi on the block diagram.

Message 15 of 25
(2,481 Views)
I tried something, maybe not correct. I will try to follow your ways.
Download All
0 Kudos
Message 16 of 25
(2,478 Views)
I use the code attached, tried to generate  aaa and bbb for 2 FG instances output.
 
 
Download All
0 Kudos
Message 17 of 25
(2,476 Views)
I tried the typed reference, but the link seems cannot be connected.
0 Kudos
Message 18 of 25
(2,468 Views)

The type gets wired to the top input of the Open.

Ben

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
Message 19 of 25
(2,463 Views)

Is the "preallocate memory" available in 8.5, since I cannot locate it in 8.2.1

May I know what is option 8.

What I assume is each thread will generate a new instance for FG by VI reference Open. Then wherever need to use the same FG, I just pass the reference to it, no matter inside or outside the port.

The new instance of FG should only be generated when I call it, but now seems cannot make it. So I am a bit confused.

If I use a vit and open it as a reference, will it generate another new copy when I use the same reference to run the FG.

Message 20 of 25
(2,460 Views)