LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Developing applications with shared variables

Hi everyone !

I currently have  a doubt and I decided to post it here and share it with you guys ! Smiley Happy

Is it ok to have two vis running at the same time - none of them are a subvi of the other - where one of them writes values to some shared variables and the other reads values from the same shared variables? If there is a problem, how can I solve it?


0 Kudos
Message 1 of 3
(2,729 Views)
Hello Giovani,

There is no problem to have two VIs running at the same time and accessing the shared variable. One writes data and the other reads data. That works fine.


The only problem that can maybe appear: Race Condition.
    - A race condition is a situation where the timing of events or the scheduling of tasks may unintentionally affect an output or data value
    - Race conditions are a common problem for programs that
execute multiple tasks in parallel and share data between the tasks
To avoid Race condition, you can use Semaphore or also Functional Global Variable.
interesting link:
Why Does Using a Local, Global, or Shared Variable to Pass Data Between Parallel Loops Cause Unexpec...

Best regards
Nick_CH
0 Kudos
Message 2 of 3
(2,724 Views)
Thanks a lot for your feedback Nick_CH ! I´ll  try some tests here and let you know their results !!!
0 Kudos
Message 3 of 3
(2,718 Views)