01-07-2010 02:16 PM
01-07-2010 02:28 PM
What do you mean by "kept in sequence"?
The use of shared variables can have the same problems of race conditions as local variables and global variables. If you are just using a single element shared variable, you can read the same data point twice, or miss a data point if you have 3 writes but only 2 reads.
But if you use network buffered shared variables, then they can act as a queue, and store the values of all the writes to the shared variable in order.
Take a look at these for more details.
Using the LabVIEW Shared Variable
01-07-2010 02:42 PM
I do just use a single element shared variable, and I only have one writer and one reader but they write and read at the same time. And the race conditions is what I'm worried about. So should I use network buffered shared variable? I know functional global can do it.
01-07-2010 03:57 PM
What kind of data are you passing through these shared variables? Is it something simple like a status boolean, or a numeric value where you only care about its current value, or if its value is one iteration old, it doesn't matter? Or is it a situation where you want to see all of the values that are ever passed through it so the loss of one single datapoint is an issue, or the duplication of a single data point is an issue?
01-07-2010 04:02 PM
01-07-2010 04:21 PM
01-08-2010 10:18 AM
Hi graffaner,
As Ravens Fan pointed out, if you use a single element shared variable, you run the risk of running into race conditions. More specifically, the risk of losing data points. Look into using network buffered enabled shared variables to avoid this. As far as duplication is concerned, you can enable the timestamp of the shared variable when reading from it, which will display the time that it was last updated. You can then compare this to the last timestamp, probably using shift registers in some way, from the last time you read from the shared variable to see if that value has been updated.
Hope this helps!
Thank you for choosing National Instruments.
Aaron P
National Instruments
Applications Engineer
01-08-2010 10:24 AM