LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Stopping Two while loops running with queuing

Solved!
Go to solution

zientist wrote:

Just wanted to ask, Troy  why do you recommend to AVOID using global and local variables?


WIth local variables, you always have the potential of race conditions. For example in your case, the consumer loop can only stop if both, (1) the global is true AND (2) a queue element arrives. You can easily have a situation where the produce loop stops, and thus the "dequeue" operation will wait forever.

 

Local variables force extra datacopies in memory. This can be an performance issue when dealing with large arrays, for example.

 

Here's an old discussion. Read it! There are plenty more imilar discussions, just do a search.

0 Kudos
Message 11 of 14
(780 Views)

Ditto what altenbach said about local and global variables. (Asides from him being absolutely correct, who would argue with a 'Night of NI'!!!)

 

Using them can also make your code a LOT harder to debug when something goes wrong.

 

It takes a fair bit of practice and experience to code completely without local varibles but once you learn the techniques you'll realise your code is neater, more reiable and easier to debug.

 

It's the Shangri-la of LabVIEW coding.

Message Edited by Troy K on 10-27-2008 09:06 AM
Troy - CLD "If a hammer is the only tool you have, everything starts to look like a nail." ~ Maslow/Kaplan - Law of the instrument
0 Kudos
Message 12 of 14
(751 Views)
Ooops, I meant 'Knight of NI'...not Night.Smiley Surprised Sorry altenbach. (I need to type slower and think faster)
Troy - CLD "If a hammer is the only tool you have, everything starts to look like a nail." ~ Maslow/Kaplan - Law of the instrument
0 Kudos
Message 13 of 14
(738 Views)
Well, may be for Halloween, I'll be the "Dark Knight of NI" 😄
0 Kudos
Message 14 of 14
(724 Views)