07-27-2013 06:45 PM
Hi all,
I have two individual subview, says SVA and SVB. They are place in the same code so they will run in parallel. SVA performs heave IO operation (read data from a big file) while SVB will run some code first, then it will use the data in read by SVA. Since SVA and SVB runs in parallel, it is hard to tell when SVB is able to read the data from SVA so I add a timer to wait some times before it reads the data from SVA.
the main program is like
in SVB, the code is like the follow, I add a timer to delay 35 secs so SVA will finish.
But if I do this way, the waiting time is not precise, if we set too short time, it will not works. If we set too long time, it works but wait too long. I am thinking to use sequence to resolve the problem
will this will solve the problem but since the first part of SVB also takes quite a long time. If I make SVA and SVB in sequence, it also wait so long to finish the code. I am thinking if it is possible to run SVA and SVB in parallel but in some way SVB can check if SVA finish so to advance to next step.
07-27-2013 07:27 PM
The images you tried to insert into your post did not show up. Did you use the "tree" icon in the toolbar at the top of the text box to insert the image?
Without the images it is difficult to tell what is happening.
From your description I sugest that you consider splitting SVB into two separate VIs. The fisrt would contain the code which can run in parallel with SVA. The second would use the output of SVA (and perhaps outputs from SVB_1) to complete the process. Then everything would be controlled by dataflow. No sequences. No timers. Minimal executon time.
Lynn
07-27-2013 07:29 PM
How are you passing data between your subVIs? If you are using a queue, then you shouldn't have to worry about this timing. SVA will write data into the queue when it is available and SVB will read data from the queue when the data becomes available. If there is no data in the queue, SVB will sit there idle until there is data.
07-27-2013 09:11 PM - edited 07-27-2013 09:29 PM
@johnsold wrote:
The images you tried to insert into your post did not show up. Did you use the "tree" icon in the toolbar at the top of the text box to insert the image?
Without the images it is difficult to tell what is happening.
From your description I sugest that you consider splitting SVB into two separate VIs. The fisrt would contain the code which can run in parallel with SVA. The second would use the output of SVA (and perhaps outputs from SVB_1) to complete the process. Then everything would be controlled by dataflow. No sequences. No timers. Minimal executon time.
Lynn
Hi, it is weird. When I post that the images were there, I don't know why it all gone.
Here I post it again. Originally, I have two progra, SVA and SVB running in parallel
and in SVB, the code looks like
I add the delay inbetween so it has enough time to wait SVA finish. However, the time change if the data length in SVA changed, so I can only use big number for estimation.
One way to resolve this issue is to put SVA and SVB in sequence
But since some part in SVB (before the delay) will run for long time too. If I do this way, the total time to run the whole code is too long. I am looking for a way to run SVA and SVB in parallel but after the first part of SVB finished it wait until SVA to finish instead of using a 'random' delay to achieve it .
07-27-2013 09:14 PM
@johnsold wrote:
The images you tried to insert into your post did not show up. Did you use the "tree" icon in the toolbar at the top of the text box to insert the image?
Without the images it is difficult to tell what is happening.
From your description I sugest that you consider splitting SVB into two separate VIs. The fisrt would contain the code which can run in parallel with SVA. The second would use the output of SVA (and perhaps outputs from SVB_1) to complete the process. Then everything would be controlled by dataflow. No sequences. No timers. Minimal executon time.
Lynn
hi Johnsold, yes what you describe is correct. That's what I mean to do. Once I read your reply, I asked my lab supervisor and he said SVA is not going to pass anything to SVB but SVA will write all stuff to an external device in GBIP and the second part of SVB will not start until everything was sent to the device.
07-28-2013 11:46 AM - edited 07-28-2013 11:47 AM
Even if you do not pass any data from one subVI to the other, you can still use dataflow to control the sequence of the tasks. The error clusters are very useful for this. In the image below SVB1 contains the code in the left frame of your sequence structure and SVB2 contains the code in the right frame. No sequence structures and no Wait required. SVB2 will not start until both SVA and SVB1 have completed. SVA and SVB1 run in parallel because they do not depend on each other.
Lynn
07-28-2013 02:05 PM
@johnsold wrote:
Even if you do not pass any data from one subVI to the other, you can still use dataflow to control the sequence of the tasks. The error clusters are very useful for this. In the image below SVB1 contains the code in the left frame of your sequence structure and SVB2 contains the code in the right frame. No sequence structures and no Wait required. SVB2 will not start until both SVA and SVB1 have completed. SVA and SVB1 run in parallel because they do not depend on each other.
Lynn
Thanks for the suggestion. It works well. But the only problem is for some reason, it is not feasible to break SVB into two separate code. But your code inspire me to use global variable to achieve it. Thanks anyway
07-28-2013 02:28 PM
Global variables for passing changing data are usually a bad idea as they can lead to race conditions.
If SVB was really structured the way you showed it in an earlier post, it will definitely be separable. Can you post SVB along with a description of what parts run parallel to SVA and what parts run after SVA?
Lynn
07-28-2013 10:36 PM
@johnsold wrote:
Global variables for passing changing data are usually a bad idea as they can lead to race conditions.
If SVB was really structured the way you showed it in an earlier post, it will definitely be separable. Can you post SVB along with a description of what parts run parallel to SVA and what parts run after SVA?
Lynn
I know it is not a good idea to use global variable. But up to now seems there is no other choice. Well, the real code of SVB is really a big one, it occupies almost 10 screens and there are so many subvis linking to that subvi. Not all vi using that SVB needs to worry about the time as described as in this post. But if I break that into too parts, all other vi linking to this one will be rewrite or relink or something anyway needed to be done. This is the problem of labview coding, so many cross-reference and I don't even dare to touch some critical code written by someone else in a big project.
07-28-2013 10:54 PM
What you think if you use Rendezvous in your code.