LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Multiple While Loops. Multithreading

Thanks for recommendation. I attached my main .vi.

 

Maybe it is better idea to use instead of local variables, I can stop the loops with Queues or Notifies?  

0 Kudos
Message 21 of 23
(320 Views)

(sorry, posting by phone, cannot see your vi)

 

The glaring race condition in this case is that the E-stop local wired to the loop termination gets read in parallel to all other code, i.e way before you write a true deep inside the case via another local. This means the loop will not stop because it has a stale value.

0 Kudos
Message 22 of 23
(294 Views)

@Revolver_90 wrote:

Thanks for recommendation. I attached my main .vi.

 

Maybe it is better idea to use instead of local variables, I can stop the loops with Queues or Notifies?  


 

You are sending data in the same queue to two separate loops. This will not work the way that you desire (or at least not the way that I think that you desire). Once one of the loops has taken data off of the queue it is unavailable for the other loop. If you're needing to send the same data to multiple loops then it might be appropriate to take a step back and ask why this is necessary. What advantage do you gain from multiple loops? I have had a few cases where it made sense (a UI loop and a processing loop, for instance, or perhaps multiple parallel processing loops in instances where one loop can't keep up), but these are rare. I think that you are overcomplicating your code.

 

Also, why are you using local variables when the terminal is unused? There's no need to make this extra copy of the data.


0 Kudos
Message 23 of 23
(256 Views)