LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Multi instance of function global

I have a multi-thread program. Everytime there is need, it will start a new thread. Each thread's code is the same, each thread will have a function global to save the data belong to this thread and exchange data for its own use with other programs.
 
How to make this function global.
0 Kudos
Message 1 of 25
(4,298 Views)

I think you need a reentrant functional global.

Just make sure you check the "Preallocate clone for each instance"

0 Kudos
Message 2 of 25
(4,285 Views)
Alternatively, you could save your functional global as a .vit and pass a reference to it in each thread.  Then Call by Reference Node and you have your functionality.
0 Kudos
Message 3 of 25
(4,271 Views)

May I know where is the setting for "Preallocate clone for each instance"

I want to call and generate a function global and finally close it dymatically everytime. How to make it? How to get the reference of the function global?

And in each thread, the same function global should be used.

0 Kudos
Message 4 of 25
(4,246 Views)
The function global may hold large volumn realtime data. which one should I choose, vi(function global) or vit.
0 Kudos
Message 5 of 25
(4,245 Views)
File->VI Properties->Execution (dropdown menu)->Preallocate Clone for Each Instance
 
 
And what I was saying was to make your functional global a .vit instead of a .vi.  That way, you can call a VI Reference to it (but you have to use a typed reference), then use the Call By Reference Node to pass data to and from the FG.
 
In the picture, the Open VI Reference and Call by Reference Node (the two on the right) are under the Application Control palette.  To obtain a typed VI Refnum, go to your front panel, and drop a VI Refnum control (under Refnum).  Go to your block diagram, right click on the new control, and select "change to constant."  Then, drag and drop the VI you want to open onto the new constant you made, and the Call by Reference Node will now display the connector panel of the VI you dragged and dropped.
 
The advantage here is that you can assign one FG to a specific thread just by passing the reference through and using the call by reference node.  The downside is that it may not be as efficient as using reentrancy, but I never trust myself with reentrancy unless it's for very simple SubVIs.
 


Message Edited by JeffOverton on 06-06-2008 07:45 AM
Message 6 of 25
(4,226 Views)


JeffOverton wrote:
The advantage here is that you can assign one FG to a specific thread just by passing the reference through and using the call by reference node. 


Can't you pass the reference through for a reentrant vi ?
Am i forgeting something? 
Message 7 of 25
(4,214 Views)
I think I may have misinterpreted how you were going to use it.  But yeah, I don't know any reason why you couldn't
0 Kudos
Message 8 of 25
(4,211 Views)
I can't think of another way to recall the same reentrant vi.
 
turbot wrote: "May I know where is the setting for "Preallocate clone for each instance""
 
Look at:  vi properties... Execution
Message 9 of 25
(4,203 Views)
Functional globals should never be reentrant. 
0 Kudos
Message 10 of 25
(4,198 Views)