LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

multithreading

I'm stuck.

I have a routine which writes IP messages over the period of tens of
seconds based on data passed into it.

I need to have this routine running independently an arbitrary number of
times concurrently. The number of threads required is determined at
run-time.

I made the routine re-entrant and put it in a while loop. Inside the
while loop the code is simply:

wait for item in the queue
Call my IP write routine

The queue is initialized with a number of items before the while loop
starts. This defines the number of concurrent threads I need.

When the routine is done, it inserts an element onto the queue.

What I want is to have is my program continually running the required
number of parallel threads. When one th
read ends, the loop should see
the new element in the queue and "immediately" start up another thread.

What happens is:

The While loop iteration doesn't end until my program finishes so I
can't get multiple threads running.

There are no outputs/dependencies from my routine, only inputs to define
the internal operation of the routine.

Can anyone shed some light on my dilemma

Grant Montag
Nortel Networks
0 Kudos
Message 1 of 2
(5,100 Views)
> I have a routine which writes IP messages over the period of tens of
> seconds based on data passed into it.
>
> I need to have this routine running independently an arbitrary number of
> times concurrently. The number of threads required is determined at
> run-time.
>
....

You probably want to look at the VI server. To respond to each request,
you will create a VI reference to the reentrant VI, set up the
parameters, and use the Run method setting the Wait until done to False.
You will probably also want the references in an array so that you can
Abort the VI if something seems wrong, you can poll the VI to see if it
is finished, or you can have the VI finish itself by removing its
reference from a protected array and Closing the reference to the
reentrant refer
ence.

Its also possible to do this by copying files on disk and
opening/running them using the server. This should only be necessary
when multiple panels need to be open, and obviously takes more time than
the reentrant reference technique.

Greg McKaskle
0 Kudos
Message 2 of 2
(5,100 Views)