LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Reading from a single process shared variable from multiple places?

I'm trying to figure out if it's okay to write to one single process shared variable, and then read from that variable in multiple other places. I am not, I repeat I am not, using the FIFO option. The only thing I care about is the instantaneous value at the time of reading. I just want to make sure I'm not having any blocking occurring.

 

Example of what I'm wondering is ok to do or not:

SV1.PNG

 

Or would I have to do something like this:

SV2.PNG

The second option would be pretty annoying since I may need to use the same value in many different places.

0 Kudos
Message 1 of 5
(717 Views)

What is wrong with just using an Action Engine? Or a Named Notifier? Or even a Global?

 

If everything is running in the same context the SPSV is just begging for abuse.


"Should be" isn't "Is" -Jay
0 Kudos
Message 2 of 5
(709 Views)

Yeah as soon as I posted this, I realized there is an actual global variable type in LabVIEW. For some reason I'm stuck on thinking that the way to implement a global variable is with a shared variable

0 Kudos
Message 3 of 5
(705 Views)

A LabVIEW Global can be very useful.  But, it does break dataflow and can lead to race conditions if you are updating the value often and without protecting the data access 

 

An Action Engine is usually safer.

Ben's famous Action Engine Nugget is always a good read. http://forums.ni.com/t5/LabVIEW/Community-Nugget-4-08-2007-Action-Engines/m-p/503801

 

And a Named Notifier can also be configured to ignore previous values or Wait until a new value is set.

 

Class data accessors are another means to protect data access.

 

We would need to know much more about exactly how you use the data to suggest which method may be best for your application. 

 

[And then you'll get multiple opinions that differ]


"Should be" isn't "Is" -Jay
0 Kudos
Message 4 of 5
(689 Views)

A Single Process Shared Variable and a Global Variable are basically equivalent.  I have not played around with SPSVs to see if there is any performance difference between the two.  Not likely anything significant.

 

As far as your use, this looks like an acceptable use of them: Tag data (single value, not a messaging scheme), 1 writer, many readers.

 

To add to what Jeff said, I will give you this link: A Look At Race Conditions


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 5 of 5
(656 Views)