LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Data Value Reference Read/Write

Is the 'Data Value Reference Read/Write' function limited to 'In place element structures'? Couldn't find it in functions pallet.

Jyo263_0-1717750746511.png

 

0 Kudos
Message 1 of 4
(444 Views)

@Jyo263 wrote:

Is the 'Data Value Reference Read/Write' function limited to 'In place element structures'? Couldn't find it in functions pallet.

Jyo263_0-1717750746511.png

 


Yes.

 

Those are not functions, they are options to a in place element structure.

 

The idea is you have to use an IPES to read\write a DRV.

 

The only other way to write a DVR's data is to create it.

The only other way to read a DVR's data is to destroy it.

 

wiebeCARYA_0-1717756178353.png

 

Message 2 of 4
(409 Views)

@Jyo263 wrote:

Is the 'Data Value Reference Read/Write' function limited to 'In place element structures'? Couldn't find it in functions pallet.

Jyo263_0-1717750746511.png

 


This is how DVR working. In general InPlace Element Structure acts as critical section, guaranteed race condition free access when you will modify your variable at different places without data copies. Better to illustrate with following simple code snippet:

DVR.png

Here you will get always "2" as output data value.

Technically under the hood the LabVIEW will call DataValueReferenceLock() function when you enter InPlace Structure, then will call DataValueReferenceUnlock() when you leave, like mutex.

It is quite simple to proof, just put 1000 ms delay inside and check how long execution will take, and you will see that both structures executed sequentially:

DVR1.png

But if you don't need to modify underlying data inside, then you can mark InPlace Structures as Allow Parallel Read-Only Access, leave write connector unwired, then the code will be executed fully parallel:

Screenshot 2024-06-07 16.01.07.png

Hope this explanation helps.

Message 3 of 4
(387 Views)

And with the Allow read only parallel access, it's fairly easy to make a .vim that accepts and DVR and returns it's value...

 

You can of course make a .vim for the write too.

 

But when you actually start using these .vims (in combination: read, modify, write) you'll have higher risk on race conditions.

 

That is the reason the IPES should be used. Without it, the DVR is just another by reference wire, with all the downsides of a reference  (that they share with global resources). Mostly: race conditions.

Message 4 of 4
(379 Views)