LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to create a multi-threaded VI?

I am working on a VI that uploads/downloads files from multiple FTP servers. Since FTP transmission is slow, I would like to open multiple FTP session at the same time, so as to maximize the network usage.  In other environments, it seems easy: I just create several worker threads, each establishes one session with a FTP server. However, how can I do this in LabVIEW?  Because the number of threads should be adjustable, I can not just put multiple FTP nodes on the diagram.  If I put them in the for loop, then those threads will be executed sequentially.  
Is there anyway in Labview to programmatically create worker threads?
0 Kudos
Message 1 of 14
(4,789 Views)

Have you considered multiple instances of the FTP connection vi?

Just for fun I wired two VI's that launch multiple instances of random number generation.

I suppose that instead of random number it can be FTP connection

_________________________________________________________________________________________________
LV 8.2 at Windows & Linux


Download All
0 Kudos
Message 2 of 14
(4,773 Views)
can you post the diagram graph or save it in 8.0 format? Can't read it...
0 Kudos
Message 3 of 14
(4,767 Views)

Hi LyLee,

      I think you want to make a reentrant VI for handling a single thread, then launch as many copies as you need (using VIs server.)

Cheers.

"Inside every large program is a small program struggling to get out." (attributed to Tony Hoare)
0 Kudos
Message 4 of 14
(4,740 Views)
this is mishklyar 's vis.. if you want to take a look..
Although i argee with tbd
Download All
0 Kudos
Message 5 of 14
(4,735 Views)
Hi tbd,Pnt what is the difference between vi's that I attached and VI server? Probably I miss somethingSmiley Happy
 
...attach here vi's for 8.0 version
_________________________________________________________________________________________________
LV 8.2 at Windows & Linux


Download All
0 Kudos
Message 6 of 14
(4,720 Views)


@mishklyar wrote:
Hi tbd,Pnt what is the difference between vi's that I attached and VI server? Probably I miss somethingSmiley Happy
 
...attach here vi's for 8.0 version


The difference is that you use templates and the suggestion was to use VIs which have been set to be reentrant. Templates spawn a completely independant VI for each load operation which would be in terms of comparison to C more like a new task each time. Reentrant VIs just create a new data space for each instance but let thv e rest remain unspawned. This means you do not really have front panels and such for the reentrant instances but for a background thread that is perfectly fine once you debugged it properly.

Reentrant VIs instantiation is less costly in terms of memory usage and also time needed for the instantiation in comparison to templates.

Rolf Kalbermatter


Message Edited by rolfk on 05-04-2008 03:58 PM
Rolf Kalbermatter  My Blog
DEMO, Electronic and Mechanical Support department, room 36.LB00.390
Message 7 of 14
(4,715 Views)

Thanks rolfk ,very useful answer, (unfortunately I can't vote yet  Smiley Happy ).

Where one can learn such a details?

_________________________________________________________________________________________________
LV 8.2 at Windows & Linux


0 Kudos
Message 8 of 14
(4,680 Views)


@mishklyar wrote:

Thanks rolfk ,very useful answer, (unfortunately I can't vote yet  Smiley Happy ).

Where one can learn such a details?



Start as NI Application Engineer and work 5 years in there, then go to an alliance member and work another 12 years there, in all that time participate in various discussion groups such as Info-LabVIEW, NI forums, LAVA and keep being curious and inquisitive all this time and you should be about there Smiley Very Happy

And this is only half way meant as joke.

Rolf Kalbermatter
Rolf Kalbermatter  My Blog
DEMO, Electronic and Mechanical Support department, room 36.LB00.390
0 Kudos
Message 9 of 14
(4,667 Views)
Hi Rolf,
      Thanks for the nice description, but maybe a slight correction or qualification is in order?


rolfk wrote:
The difference is that you use templates and the suggestion was to use VIs which have been set to be reentrant. Templates spawn a completely independant VI for each load operation which would be in terms of comparison to C more like a new task each time. Reentrant VIs just create a new data space for each instance but let thv e rest remain unspawned. This means you do not really have front panels and such for the reentrant instances...


Message Edited by rolfk on 05-04-2008 03:58 PM

      In LV  7.1 this was true, however, as of LabVIEW 8.2, reentrant VIs can have their own FP.  I don't know about VITs - haven't used them much.
 
Cheers.
"Inside every large program is a small program struggling to get out." (attributed to Tony Hoare)
0 Kudos
Message 10 of 14
(4,651 Views)