LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

start a new thread

Hello,

I'm running LV 5.1.1 on a W98 PC.
I'd like to know how to programmatically start another thread from
within labview. I.e. is there anyway to duplicate the unix fork?

I'd like to build a server (parent.vi) in labview that receives a
request, starts a vi (child.vi) to handle the request and spawns it off
as a low priority task/thread so that the server may continue to process
additional incoming requests. When child.vi is complete it
exits/terminates.
I've looked into the vi server documentation and attempted a trick
Greg M. mentioned ... copying the child.vi to a new name, loading it and
executing it, but this forces a loop in the server to keep track of the
children and call them sequentually. As some tasks ar
e quick, others
longer, I'd sure like to just let each child.vi run independently and
terminate when finished.

all
suggestions welcome,
thanks,

-- Bill --
0 Kudos
Message 1 of 3
(2,506 Views)
The method you described should work as you expect.

When you open the child.vi copy and use "Run VI" method, the child runs by
itself as a top VI.
After it is finished, its VI reference must be closed to release it from
memory and the file copy eventually deleted.
The child.vi can do this before it exits if you pass to it its own VI
reference (I use "Set Control Value") from the parent.vi.
Then when the child.vi task is finished, it can delete its file copy ( using
"Get VI path" method) and close its VI reference.
Make sure that closing the VI reference is the last thing you do in the VI
since the close halts the VI execution and release it from memory.

Jen-Pierre Drolet
Scientech R&D inc.


William R. Doggett a écrit dans le messa
ge :
38F38ECD.C4B01402@larc.nasa.gov...
> Hello,
>
> I'm running LV 5.1.1 on a W98 PC.
> I'd like to know how to programmatically start another thread from
> within labview. I.e. is there anyway to duplicate the unix fork?
>
> I'd like to build a server (parent.vi) in labview that receives a
> request, starts a vi (child.vi) to handle the request and spawns it off
> as a low priority task/thread so that the server may continue to process
> additional incoming requests. When child.vi is complete it
> exits/terminates.
> I've looked into the vi server documentation and attempted a trick
> Greg M. mentioned ... copying the child.vi to a new name, loading it and
> executing it, but this forces a loop in the server to keep track of the
> children and call them sequentually. As some tasks are quick, others
> longer, I'd sure like to just let each child.vi run independently and
> terminate when finished.
>
> all
>
suggestions welcome,
> thanks,
>
> -- Bill --
>
0 Kudos
Message 2 of 3
(2,506 Views)
Thanks for the "Set Control Value" tip. I was using a "call by reference" node
to initialize the child vi. Seems one can not intermix the "call by reference"
and the "invoke node" blocks in this case????? When I used the "Set Control
Value" things ran as expected.

thanks
again,
--
Bill --

Jean-Pierre Drolet wrote:

> The method you described should work as you expect.
>
> When you open the child.vi copy and use "Run VI" method, the child runs by
> itself as a top VI.
> After it is finished, its VI reference must be closed to release it from
> memory and the file copy eventually deleted.
> The child.vi can do this before it exits if you pass to it its own VI
> reference (I use "Set Control Value") from the parent.vi.
> Then when the child.vi task is finished, it can delete its file copy ( using
> "Get VI path" method) and close its VI reference.
> Make sure that closing the VI reference is the last thing you do in the VI
> since the close halts the VI execution and release it from memory.
>
> Jen-Pierre Drolet
> Scientech R&D inc.
>
> William R. Doggett a �crit dans le message :
> 38F38ECD.C4B01402@larc.nasa.gov...
> > Hello,
> >
> > I'm running LV 5.1.1 on a W98 PC.
> > I'd like to know how to programmatically start another thread from
> > within labview. I.e. is there anyway to duplicate the unix fork?
> >
> > I'd like to build a server (parent.vi) in labview that receives a
> > request, starts a vi (child.vi) to handle the request and spawns it off
> > as a low priority task/thread so that the server may continue to process
> > additional incoming requests. When child.vi is complete it
> > exits/terminates.
> > I've looked into the vi server documentation and attempted a trick
> > Greg M. mentioned ... copying the child.vi to a new name, loading it and
> > executing it, but this forces a loop in the server to keep track of the
> > children and call them sequentually. As some tasks are quick, others
> > longer, I'd sure like to just let each child.vi run independently and
> > terminate when finished.
> >
> > all
> > suggestions welcome,
> > thanks,
> >
> > -- Bill --
> >
0 Kudos
Message 3 of 3
(2,506 Views)