annulla
Visualizzazione dei risultati per 
Cerca invece 
Intendevi dire: 

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
Messaggio 1 di 25
4.733Visualizzazioni

I think you need a reentrant functional global.

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

0 Kudos
Messaggio 2 di 25
4.720Visualizzazioni
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
Messaggio 3 di 25
4.706Visualizzazioni

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
Messaggio 4 di 25
4.681Visualizzazioni
The function global may hold large volumn realtime data. which one should I choose, vi(function global) or vit.
0 Kudos
Messaggio 5 di 25
4.680Visualizzazioni
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
Messaggio 6 di 25
4.661Visualizzazioni


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? 
Messaggio 7 di 25
4.649Visualizzazioni
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
Messaggio 8 di 25
4.646Visualizzazioni
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
Messaggio 9 di 25
4.638Visualizzazioni
Functional globals should never be reentrant. 
0 Kudos
Messaggio 10 di 25
4.633Visualizzazioni