LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to avoid race conditions??

Solved!
Go to solution

stu22,

 

Depending on the requirements, a Producer-Consumer or State Machine are just a couple of ways to avoid race issues caused by variables.  The use of Functional Global Variables/Action Engines would also help your code.  Just too many loops running in parallel.

 

Definitely an echo in here today.  Smiley Very Happy

 

In looking at your code, I did notice that you are reading individual cFP channels the hard way.  See below.

 

Message Edited by Wayne.C on 01-29-2010 09:32 AM
0 Kudos
Message 11 of 17
(1,374 Views)
Could you also post in LV 7.1, please?
0 Kudos
Message 12 of 17
(1,347 Views)

leonardolt wrote:
Could you also post in LV 7.1, please?

 

Who are you asking?  Which attachment?

 

If you are asking the original poster, it is a bit much to ask someone who is a newer user to save as a much older version.  LV7.1 is 5 versions older than the current version.  If they don't have LV 8.0, which they probably don't if they are a newer user asking questions, they aren't going to be able to.

0 Kudos
Message 13 of 17
(1,337 Views)

 Dear Ravens, you are right, I was asking Stu to post his lib in LV 7.1. I just have that version to work with, so I don't even know how it has to be done in other versions.

 

 Now, Stu, if you don't feel confortable posting your file in such an old format, I'm awful sorry, it was really not my intention to bother you. I wasjust trying to help.

 

 Leo

0 Kudos
Message 14 of 17
(1,332 Views)

 A few interesting resources for your peruseal...

 

Video: Local Variable, Global Variable, and Race Conditions

http://zone.ni.com/devzone/cda/tut/p/id/7585

 

Tutorial: Local Variable, Global Variable, and Race Conditions

http://zone.ni.com/devzone/cda/tut/p/id/7585

 

Are LabVIEW global variables good or bad, and when is it OK to use them?

http://zone.ni.com/devzone/cda/tut/p/id/5317

Rich Roberts
Senior Marketing Engineer, National Instruments
Connect on LinkedIn: https://www.linkedin.com/in/richard-roberts-4176a27b/
0 Kudos
Message 15 of 17
(1,295 Views)

Paul,

What about using reentrancy to resolve Race Conditions? As I understand it, clones of the shared resource will be created to allow simultaneous access.

0 Kudos
Message 16 of 17
(681 Views)

@ooyeniyi wrote:

Paul,

What about using reentrancy to resolve Race Conditions? As I understand it, clones of the shared resource will be created to allow simultaneous access.


If you are marking your clones as rerentrant you are actually increasing the odds of races conditions. If you are accessing a shared resource of some type (global or local variable) and you are spawning reentrant clones you are increasing the number of threads/processes that will be trying to access the data at the same time. This is not an issue if you have a WORM (Write Once Read Many) global or local variable since the data is static and you are simply reading it. However, once you start modifying the data in more than one place, you will have race conditions unless you implement some type of locking mechanism.

 

BTW, you do realize that your are replying to an 11 year old thread. Quite possible that none of the people originally involved in th ediscussion are still here.



Mark Yedinak
Certified LabVIEW Architect
LabVIEW Champion

"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot
0 Kudos
Message 17 of 17
(668 Views)