LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

VIServer and thread control

I am trying to write code to spawn multiple instances of the same re-entrant VI, called calculate.  The calculate takes as inputs:

 

Queue Reference - this is how the data is passed to the vi.

Operation - the VI can calculate different operations (say std, var, etc)

Start Index - the start of the calculation index on the data array

Stop Index - the stop of the calculation index on the data array.

 

The main VI would spawn N copies of the VI and then pass data to the SubVI.  It would seem that if I truly wanted the VI's to run in parallel I would need to be able to set the thread and execuation system that it runs in.  Can this be done with VIServer?  Don't VIServer VI's run out of process, and if so how do you control what thread they run in?  Do they automatically run in a new thread in a new process?

 

Anyone tried anything like this?

 

Thanks for looking.

0 Kudos
Message 1 of 6
(3,033 Views)

The preferred execution system of a VI can be set using the Execution:Preferred Exec System property for a VI reference.

 

Based on your description it doesn't sounds like you actually need reentrancy, but rather a template VI. 

0 Kudos
Message 2 of 6
(3,018 Views)

Hey Rammer,

 

Check out this thread on creating the vi template and calling it dynamically in its own thread.

 

Hope this helps

 

-Ben

Hope this helps.
-Ben

WaterlooLabs
0 Kudos
Message 3 of 6
(2,994 Views)

Isn't reentrancy needed because I am going to have the same VI running multiple times in separate loops/instances?

 

Rammer

0 Kudos
Message 4 of 6
(2,990 Views)

Ben,

 

Based on that thread:

 

1.  All VI's launched via VIServer are in a their own thread - has anyone ever verified this?  Does it ignore the execution properties of the VI?

2.  What is AE referring to?

 

John

0 Kudos
Message 5 of 6
(2,988 Views)

rammer wrote:

Isn't reentrancy needed because I am going to have the same VI running multiple times in separate loops/instances?


It depends on whether you're calling the subVI statically or dynamically and whether you're trying to do this in a loop, or you simply have multiple instances of the subVI on a block diagram:

 

  • If you have a reentrant subVI that you want to call multiple times and you want to place the subVI on the block diagram (static call), then reentrancy is only useful is you have the subVI placed multiple times on the block diagram. If you have the subVI in a loop reentrancy does you no good.
  • If you have a reentrant subVI that you call dynamically then reentrancy also does you no good.
  • If you use a template VI then the subVI does not need to be reentrant. Instantiating the template creates a new copy of the VI under a new name, so it's the same as running multiple VIs simultaneously. The downside is that the subVI will be seen as "new" VIs and will be asked to be saved when closed, though this can be handled by your code. 


See the attached example for a few scenarios.

 

P.S. AE = Action Engine

0 Kudos
Message 6 of 6
(2,976 Views)