LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How can I create multiple parallel threads programaticaly?

Solved!
Go to solution

Hi all!

 

I am working in RF testing lab I have to "stress" an equipment using Telnet/SNMP/TFTP and other stuff, so I have to use parallel model for this.

But my problem is that the user will select how many parallel threads will start, according to the type of the equipment!

 

I have created a reentrant VI that loops until a global goes false.

From another GUI VI, the user inserts a random number, for example 3, and into the GUI VI I have to create 3 running threads using the reentrant VI.

 

In GUI VI I used a loop for "Open VI reference", building an array of references to the first reentrant VI and then I tried to run them using "Call By Reference" into another loop, but only the first VI is running.

By placing "Call by reference" three times into the GUI VI, all works OK because the reentrant VI is cloned three times and parallelism is offered, but I need to establish the number of clones programatically.

Is there a way to clone VIs at runtime? Or... is there another approach for this task?

 

Thanks!

Tiberiu

Message 1 of 7
(4,506 Views)

Hi Tiberiu,

you can create a vit (Labview template). With each run call you create a new instance of it (load it dynamically). You can load a new instance of it, as much as you need. All subvi's used by the vit's except the AE should also be reentrant.

 

Mike

Message Edited by MikeS81 on 01-27-2009 03:30 PM
0 Kudos
Message 2 of 7
(4,500 Views)

Hi Mike and thanks for your reply!

 

I saved my VI as template and then run it into a three steps loop. I got the same result, that means the application is running only the first clone of the VIT and remains into the first step of the loop, instead of creating 3 instances of the VIT.

 

Could be a problem that the VIT has a while loop inside?

 

Tiberiu

0 Kudos
Message 3 of 7
(4,480 Views)
Solution
Accepted by topic author tiberiud

Hi Tiberiu,

no the while loop is no problem, but you should load the vi dynamically. See the attached picutre. You can set all the controls with the invoke node.

 

Mike

Message Edited by MikeS81 on 01-27-2009 04:24 PM
Message 4 of 7
(4,473 Views)

Great! Thank you, it works!

 

I have one more question: how this will work when I will build the executable aplication?

The VIT will be distributed automatically and from main application I should determine the path of VIT?

 

Tiberiu

0 Kudos
Message 5 of 7
(4,458 Views)

Hi Tiberiu,

you have to insert the VIT's to the dynamically loaded section to make sure that they are part of the executable. You can use the "App.typ property to decide if you run in development mode or in the executable. If you run as executable you can use the "current vi's path" function with one "strip path" and then one "build path" with the vit name. All vi's in the executable lie side by side inside the exe.

 

Mike

Message 6 of 7
(4,454 Views)

It's perfectly clear for me right now!

 

Thanks and happy wiring!

0 Kudos
Message 7 of 7
(4,452 Views)