11-11-2016 08:04 PM
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?
11-11-2016 09:08 PM - edited 11-11-2016 09:09 PM
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
11-11-2016 11:04 PM
11-13-2016 02:46 PM
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.
11-13-2016 04:13 PM - edited 11-13-2016 04:24 PM
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.
11-14-2016 07:16 AM
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.