LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Are network published shared variable write & read actions atomic

Solved!
Go to solution

Hi,

 

I've got a very basic question about shered (network published) variables.

I think I know the answer already but since I could not find it in my documentation I thought it safest to ask ...

 

Are the read and write operations on a shared variable atomic actions?

 

To be more specific: on my Real Time target I am creating an array with data (each element being a cluster with name, value and type or the configuration element) and when the array is complete I'm storing this in a network published shared variable.

On my (Windows) host I am polling (while loop) until the array contains at least 1 element, when this is true I am parsing all elements in the array.

 

Is there a chance that, on reading the shared variable, the array contains a subset of the original array on the RT target (i.e. the read action is taking place while the write is still in progress).

Or is the read action delayed until the write is finished? (i.e. both write and read actions are atomic even over the network)

 

I think the latter is true but could not find any evidence in the documentation.

 

Regards,

 

Rob

0 Kudos
Message 1 of 3
(2,251 Views)
Solution
Accepted by topic author Rob65

Hello Rob,

 

Yes, you can only access the whole value, of the data-type you use, at once. So for array data-type, the whole value is actually the complete array. Then, yes, you can see reading and writing as atomic actions.

 

But, on the other hand, you can lose data if the RT system rewrites the variable before that the host had time to read it. In order to prevent that, you can enable buffering for the variable. See those following links for more info:

http://www.ni.com/white-paper/4679/en

http://zone.ni.com/reference/en-XX/help/371361H-01/lvconcepts/buffering_data/

 

Finally, you can also enable an RT FIFO on your RT target if you need to send data through the variable in an RT deterministic section. Also, see more info:

http://zone.ni.com/reference/en-XX/help/370622H-01/lvrtconcepts/rt_projectvariable/

Cédric | NI Belgium
0 Kudos
Message 2 of 3
(2,179 Views)

Thanks for the info.

 

this confirms that this works as expected - which is always nice Smiley Happy

 

Regards,

 

Rob

0 Kudos
Message 3 of 3
(2,173 Views)