From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
01-29-2010 03:37 AM
Hi, ive been doing Labview for 10 years now. And its the first time ive come across or its effected my code. I have a lot of code that executes at the same time. And done for years, any good practice to avoid this ever happening again??
Stu
Solved! Go to Solution.
01-29-2010 03:55 AM
Make sure operations that are dependant on each other are wired/sequenced so they're forced to execute in order. It's often easiest to control through error wires.
/Y
01-29-2010 04:32 AM
Avoid variables (at all costs?!). Lock critical sections.
How to do this:
Implement an appropriate architecture.
hope this helps,
Norbert
01-29-2010 05:09 AM
01-29-2010 05:41 AM
Hi Stu!
Maybe you could post a picture of your diagram. Thus, it would be easier for us to help you.
Best regards
Leo
01-29-2010 05:54 AM
Hi, my entrire llb is here on this thread. Basically its do with upper left loop which reads the opc mass spec read. I'm trying to find what is interefering with it?? giving out of sequence results.
http://forums.ni.com/ni/board/message?board.id=170&thread.id=471306
01-29-2010 06:46 AM
01-29-2010 07:29 AM
I spent an entire course on race conditions and concurency in grad school, and to avoid race conditions you have to understand why they arise.
Race conditions occur when multiple concurent or parallel processes access a shared resource. Furthurmore it is mostly troublesome when 2 or more threads/processes are activly modifying a resource. So first identify the candidates for this when architecting your application. If you only have one thread you should be safe (although this is getting more fuzzy since there is the ability to run in parallel). Next is there any resources/variables that are needed in 2 threads at the same time, and if so do you modify the value in one or more threads. If so you have to deal with synchronization.
Traditionally you talk about semaphors, locks and mutexs. All methods for locking critical code (ie resources that are possible race condition sources).
BUT WE ARE IN LABVIEW. Labview has one easy method that could be easier to use, the functional global.
since vis that are not marked for reentrancy are essentially nice way for protecting data and locking your critacal sections. Only one thread can access and or modify the data stored in the vi at a time. Other threads will block and wait on the resource.
This was much harder to implement in c.
Either way the way you deal with race conditions is to
1. Identify critical sections and resources that can cause race conditions (usually shared resources with multiple writers)
2. Lock the resource until done (avoid deadlocks while doing so-but this is another discussion)
Unlike traditional bugs, concurent bugs are more random and very difficult to reproduce/test for so you will have to deal with them in the design architecture stage.
01-29-2010 07:33 AM
01-29-2010 07:38 AM
Functional Global is a type of Action Engine (AE) as I discuss in this Nugget.
That nugget discusses this image
in the discusion of how the critical section is protected.
Ben