LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

shared variable synchronization

Hi,
I am trying to send data between computers. I have used shared variable to do this and to avoid race condition I have append "?sync=true" in URL to synchronize access to shared data.  But when I run  Send and Read VI, race condition sometimes still appears? Even when I run both VIs on same PC.
I have attached VIs, if someone would like to try it.

Thanks,
andrej
Message 1 of 2
(2,520 Views)
You maybe running into a race condition even though you are appending the '?sync=true' tag is because the synchronous operation only ensures that the dataflow proceeds after the the datasocket has communicated the update to the shared variable engine. The race condition maybe caused due to the time that the shared variable engine takes to update the variable. The second iteration of the while loop may still read the value of the SVRead variable from the previous iteration which might cause a race condition. To avoid this possibility, I implemented a tri-state SVRead variable. Instead of using a boolean, I used an integer to check the status so that the Sender/Receiver do not wait for the same value of SVRead which could potentially cause a race condition.

Assuming that the SVRead variable will be initialized to a '0' Value, refer to the following image for more information on how the SVread values are being cycled.
Also, I am attaching the editted version of your VIs so that you can test it out.

Please let me know if this helps in resolving the race condition.
Mehak D.
0 Kudos
Message 2 of 2
(2,482 Views)