LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

FGVs may help avoid race conditions, but do they force execution order between loops?

I am looking at some popular documentation on FGVs where they are showcased as useful for avoiding race conditions in a parallel multi-loop secnario, but my question is what about forcing execution order?  Yes the FGV being a non re-entrant vi ensures  both loops cannot run at the same time (only one instance at a time), but then what about sequencing / execution order?

Can it then be said that if a diferent order of execution from one loop to another will affect the end results , FGVs may not suitable?

[BADGE NAME]

0 Kudos
Message 1 of 6
(2,964 Views)

Were you viewing Nancy Hollenback's talk on FGV's?  You probably saw that FGV's can prevent Race Conditions in simultaneously-running, asynchronous routines.  Did you see the word "asynchronous" in the previous sentence?  The implication is they run independently, and there is no forced execution order between these loops.  If the two loops run at the same rate, and you need to force order (for instance, one loop "produces" something and the other loop "consumes" it), then don't use an FGV, use a Queue (or Channel) in the Producer/Consumer Design Pattern.

 

Bob Schor

Message 2 of 6
(2,938 Views)

Sure that makes sense. Just wanted to make sure I didn't misunderstand the idea. Thanks.

[BADGE NAME]

0 Kudos
Message 3 of 6
(2,924 Views)

For questions like this, you want to stop and ask yourself "How would data flow impact this?"

 

At their base, FGVs are merely a subVI.  When does a subVI execute?  (When it gets all of its inputs).  You can only force the order of execution by knowing the answer to this.  Once you realize you'd require a data dependency between the two loops to force the order of execution, you'd know you'd need something beyond the FGV to handle that task.

This is a thought exercise you should ask ANY time you're wondering about order of execution and not just in this case.

0 Kudos
Message 4 of 6
(2,840 Views)

natasftw,

 

That question was based on a video i saw apparently trying to show the use of FGVs but because it was also discussed along the lines of "producer-consumer" it appeared to portray that they fall within the same capabilities as queues. Was not same video Bob thought i saw though. My question was to affirm my personal position which is not different from what Bob said too. So yes, i did pause and I did ask myself that question and if you read my post it shows what my thoughts were already, but just wanted to get some opinion from the forum. I think Bob already re-affirmed that.

[BADGE NAME]

0 Kudos
Message 5 of 6
(2,832 Views)

And now for a shameless plug: Are Global Variables Truly Evil? (even a video there!)

And the document that started the presentation: A Look At Race Conditions

 

In summary, Action Engines prevent race conditions by protecting "critical sections" of code.  They cannot force execution order between parallel processes.  If order is really needed, they should be in the same loop and use data flow to force order.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 6 of 6
(2,798 Views)