07-03-2008 04:15 PM - edited 07-03-2008 04:19 PM
07-03-2008 10:55 PM
Ravens Fan wrote:
It is really a race of OUTGOING wires. If the error wire coming out of subVI 1 sends its data onto subVI 2, which now has all of its inputs as the reference was already passed to it, and it executes the code to get the value of the reference, BEFORE the data coming out of subVI 1 on the blue wire arrives at the terminal of the indicator, then yes you would have a problem.
07-03-2008 11:32 PM
parthabe wrote:
Did you meant that there is a chance that the Error Out terminal of SubVI1 may give its (default)output to SubVI2 before SubVI1 has finished its execution?
07-04-2008 01:24 AM - edited 07-04-2008 01:26 AM
If the Value property is read inside the second subVI, then there is a race condition without any shadow of a doubt.
You should note that a race condition is a condition - it isn't about whether you actually saw the code behaving not like you want, but whether the code might behave in that way. Even if you added a 10 second wait in the second subVI before reading the property, there would be nothing to guarantee that the calling VI would not wait 12 seconds before updating the indicator. As such, you can't expect to see race conditions by running the code - you need to learn to avoid them and recognize them if you see them.
There was even an example mentioned in this thread - the code works fine in the IDE, but there were issues when the code was built into an executable.
07-04-2008 02:46 AM
@Ravens Fan wrote:
Let's say that data isn't instantly transferred from one end of the wire to the other. The CPU could schedule the 2nd subVI to run and complete some or even all of its execution because the error cluster and the control reference are both available at its connector pane, before the CPU has decided to update the numeric indicator with the value that has come out of the 1st subVI. The execution of the 2nd subVI is not dependent on the fact that the indicator has been updated, really only that the 1st subVI has finished.If data isn't instantly transferred from the source of the wire to its destination, then there is a possibility of a race condition based on how fast the data flows down the wires.
@tst wrote:
Even if you added a 10 second wait in the second subVI before reading the property, there would be nothing to guarantee that the calling VI would not wait 12 seconds before updating the indicator. As such, you can't expect to see race conditions by running the code
07-04-2008 03:35 AM
DavidU wrote:
Could it also depend on the the data type?
is it possible to read a value while it is being updated, ie starting to read a large array, before new values have finished being put into it?
07-04-2008 05:06 AM
07-07-2008 08:45 AM
Ravens Fan wrote:This is an interesting thread and seems to talk about a different aspect of race conditions from the usual threads where people are posting code that is just competing local variables.
07-07-2008 09:10 AM
StevenA wrote:
I agree this thread brings up an interesting (and I think less frequently thought of) aspect of the wires.