The Daily CLAD

Community Browser
cancel
Showing results for 
Search instead for 
Did you mean: 

Re: The Dataflow Paradigm #4

SercoSteveB
Active Participant

The following poorly written VI contains a race condition.  What are the possible value(s) of Numeric Value In following exection of the VI?

DataFlow #4.jpg

a) Numeric Value In = (Numeric Value In x 7) + 2

b) Numeric Value In = (Numeric Value In + 2) x 7

c) Numeric Value In = Numeric Value In x 7

d) Numeric Value In = Numeric Value In + 2

Comments
Mat32
Member

A) First the control and then the local variables

SercoSteveB
Active Participant

Hi Mat32.  I agree.  From my experience execution tends to be in the order, Control then locals.  I am not sure you can always assume that though, maybe someone at NI could comment.

I really didn't think that deeply about it when 'modifying the question from the NI Core 1 course notes'.  For me it was really about the lack of Data Flow between the two sections of code and how that might impact the result.

SercoSteveB
Active Participant

Answer: A,B,C & D

As there is no data connection between the two sections of code I like to think about there being four possible exection orders:

1)  When the top section of code completes before the bottom section begins (giving the result in A)

2)  When the bottom section of code completes before the top section begins (giving the result in B)

3)  When the bottom section of code starts just before the top section, completing first but having its result overwritten when the top section completes (giving the result in C)

4)  When the top section of code starts just before the bottom section, completing first but having its result overwritten when the bottom section completes (giving the result in D)

mini09
Active Participant

Steve as you mentioned in the point 2 hw come the bottom section of the code will be executed first before the value is initialized to local variable? How does a multiple program on the same program runs? which runs first from bottom to top or top to bottom?

SercoSteveB
Active Participant

gnshmrthy.  I think the key point to take away from the is question (or the one I was thinking about when I wrote it) is that LabVIEW execution order is defined by the dataflow, if the dataflow (additional resource) is broken (as in the question) you cannot define the execution order, and that may have more reaching impact on the result than is initially obvious.

In addition; I am fairly sure that unmodified code with broken dataflow will have the same execution order each time you run it), but once you modify that code you run the risk of your dataflow changing to something different.  Obviously if you maintain dataflow through your VI you are defining the exection order so this issue never arises.

Andreas.Bernau
Member

So I learned today: Following the experience of other LabVIEW developers we can assume A. But to exclude possible side effects and to have clear predictable LabVIEW code we should count with A, B, C, D. At least as long National Instruments gives no specifications.

We talk about LabVIEW 2009. Now version 2015 is released. So in case there are changes please let us know. Thank you very much.

chan1989
Member

I tried the snippet with LabVIEW 2015. I get random output. Still A, B, C and D are all possible answers.

ersmt444
Member

Image broken

mohamedtanveej17
Member

HI steve,

   when i see the question i think as i go for option A

   but I try it with LabVIEW , with Local variable it gave me like option c whether it is run based precedance 

   I understand Race Condition, but here i felt i don't get a Race condition , Is it Right?