LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

writing to a global cluster in multiple vis

I need some suggestion to fix an issue I created. I have an array of clusters in a global variable. I have multiple vi's reading and writing to these globals. The vi's that are writing to this global cluster are independent of each other. I need to find a way to prevent one vi from overwriting information that was writen from a different vi. Its a little hard for me to explain! If vi 1 reads the global and vi 2 reads the global at the same time, vi 1 updates some information and writes back to the global, vi 2 updates different information and writes back to the global just after vi 1 wrote to the global. Vi 2 has just written over the information that vi 1 just wrote to the global.

I need some suggestion to prevent this from happening. Any ideas?

0 Kudos
Message 1 of 3
(2,937 Views)

Just some keywords, so you get the solution by searching the forum (I don't have the bookmarks at hand):

 

What you face is a 'race condition', the real classic example. Remove the global at all. Try replacing it with an 'LV2 Style Global' or 'Action Engine' (two terms for the same thing). Ben has written a nugget about it.

 

Felix

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

Hi Joe John,

 

Take a look at this KnowledgeBase too:

Using a Local, Global, or Shared Variable in Parallel Loops Can Cause Race Conditions

 

It address race conditions and gives you some links for further explanations and resources.

 

Kristen H.

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