LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

race condition

can someone help me with this..
i have a race condition that i cant seems to fix.
everytime i run it, i would have different result.
the while loop will start first one time.
then if i run it another time, the sequence loop will.
what can i do to successfully get the while loop to run first, keep running till the end of the program because my while loop is just telling me the current date/time.
after while loop has started, i want the sequence to start.
can someone look at this and tell me what i did wrong.
thanks

Best regards,
Krispiekream
0 Kudos
Message 1 of 24
(4,012 Views)

Best regards,
Krispiekream
0 Kudos
Message 2 of 24
(4,010 Views)
What you are seeing is not a race condition. When you have two structures that are not dependent on each other by means of data, then LabVIEW will run them in parallel. As for which one starts first, there's no way to know. If you absolutely must have the sequence structure start after the while loop then you need to use some mechanism, like a notifier or an occurrence.

You can take a look at the LabVIEW Help as well as the examples that ship with LabVIEW for these synchronization functions.


Message Edited by smercurio_fc on 06-12-2008 04:30 PM
Message 3 of 24
(3,993 Views)
great..thanks
if that is the case, wouldn't adding a wait time would solve it.





Message Edited by krispiekream on 06-12-2008 04:59 PM
Best regards,
Krispiekream
0 Kudos
Message 4 of 24
(3,982 Views)
I was providing a generic answer. Putting that wait time will not prevent other code within that sequence frame from starting up since there's nothing tying the wait to the rest of the code. Again: dataflow execution, not sequential execution. You could, of course, simply add a frame at the beginning and place the wait there.

I will let purists here chime in and ask: "Why are you using sequence frames?"
Message 5 of 24
(3,972 Views)
hmmm, i am using a flat sequence.
i dont know why, but i thought that to initialize things, normally a flat sequence is used.
you do make a very great point about data execution.
i tried looking up the forum for example on your first solution...
notifier and occurence, but i didn't see any. so i am still trying to figure out how to do that..


Best regards,
Krispiekream
0 Kudos
Message 6 of 24
(3,966 Views)


smercurio_fc wrote:
What you are seeing is not a race condition.
I thought that fits the definition of a race condition very well 🙂
 
Krispy: There is something terribly wrong with the color palettes of your diagram. I would strongly suggest to keep structures at their default colors. This is not an art contest. 😄
Message 7 of 24
(3,956 Views)
hahaha. really?
i like the color.
its easier to distinguish one set of structures from another.
i thought i see ppl do that all the time.hahaha
Smiley Happy


and oh yeah,
adding a before case then wait time didn't do the job.



Message Edited by krispiekream on 06-12-2008 06:01 PM
Best regards,
Krispiekream
0 Kudos
Message 8 of 24
(3,953 Views)
 Can you post the VI?
0 Kudos
Message 9 of 24
(3,922 Views)


and oh yeah,
adding a before case then wait time didn't do the job.

Message Edited by krispiekream on 06-12-2008 06:01 PM

That's right. You're just making the race condition slightly less likely. You can synchronize the execution of parallel structures in LabVIEW using many tools, most notably the VIs in the Synchronization palette. The easiest to start with are the Occurrences. Once you get a hold of those, check out Queues, Notifiers, and so on. All fun stuff and immensely useful for destroying race conditions.

Par example... The first frame of the case structure waits for the Occurrence to fire, which doesn't happen until the first iteration of the While loop. So the second frame of the case structure is guaranteed not to start before the while loop.





Message Edited by Jarrod S. on 06-12-2008 08:56 PM
Jarrod S.
National Instruments
0 Kudos
Message 10 of 24
(3,904 Views)