BrokenArrow Posted June 20, 2007 Report Share Posted June 20, 2007 Since my job lately has been to debug existing code, I have found several race conditions. Sometimes I can spot these just by looking at the code, but often it's just by happenstance that I find them - usualy by doing things like initializing local variables with some bogus number or by drawing frames around code and throwing in a few delays here and there. IS there a trick to debugging race conditions? Speaking of (what I call) race conditions, is the attached picture a true race condition? On this VI, the error was occuring every 3rd or 4th entry into the VI. I fixed the issue by intializing the "Char Offset" to 0. A few moments later I moved the wire as shown and it fixed it, and got rid of the local I added. Since the problem was initially fixed by toying with a Local Variable, I defined this problem as a Race Conditions. Is it? Any advise for further reading? THANKS! Richard Quote Link to comment
Ton Plomp Posted June 20, 2007 Report Share Posted June 20, 2007 QUOTE(BrokenArrow @ Jun 19 2007, 03:32 PM) I defined this problem as a Race Conditions. Is it? Definitely, it just bypasses flow programming! Ton Quote Link to comment
Jim Kring Posted June 20, 2007 Report Share Posted June 20, 2007 QUOTE(BrokenArrow @ Jun 19 2007, 06:32 AM) is the attached picture a true race condition? It is a classic example of a race condition. Quote Link to comment
jpdrolet Posted June 20, 2007 Report Share Posted June 20, 2007 Strictly speaking there is still a possible race condition in your fix since nothing garantees that the char offset terminal is written before entering the loop and reading its local. The safest way to implement this is to add a shift register in the for loop and feed it with the char offset wire. http://forums.lavag.org/index.php?act=attach&type=post&id=6148 You can now see that you don't even need a local except for display purposes Quote Link to comment
LAVA 1.0 Content Posted June 20, 2007 Report Share Posted June 20, 2007 QUOTE(BrokenArrow @ Jun 19 2007, 09:32 AM) Any advise for further reading? The placement of the control and indicator don't follow the left-right top-bottom conventions of the LabVIEW Development Guidelines. The race condition would be more obvious if the conventions were followed. I had to do a double-take because the indicator was above the control and wired from the right. These sorts of problems can be found with the VI Analyzer Toolkit. I've been using this more and more and like it (although its a bit anal sometimes) I need to make my own configuration at some point. Quote Link to comment
BrokenArrow Posted June 21, 2007 Author Report Share Posted June 21, 2007 QUOTE(LV Punk @ Jun 19 2007, 12:06 PM) ...I had to do a double-take because the indicator was above the control and wired from the right.... Indeed. This is 5.1, which doesn't show the flow direction on terminals and lets you wire from any direction. This inherited code is full of that kind of qurky wiring. QUOTE(jpdrolet @ Jun 19 2007, 11:06 AM) The safest way to implement this is to add a shift register in the for loop and feed it with the char offset wire. Sweet. If I had a dollar for every time this code used a local rather than a shift register, I could buy this website and host porn. Nah, they'd never allow porn on the internet. QUOTE(Jim Kring @ Jun 19 2007, 10:16 AM) It is a classic example of a race condition. Thanks Jim and Ton. Every time I mention "race condition" around here they look at me like I'm making sh!t up. -Richard Quote Link to comment
LAVA 1.0 Content Posted June 21, 2007 Report Share Posted June 21, 2007 QUOTE(BrokenArrow @ Jun 19 2007, 09:05 PM) Every time I mention "race condition" around here they look at me like I'm making sh!t up. I've created a wiki entry for [wiki]Race Condition[/wiki]. There's lots of great info on these forums. Maybe they should join LAVA (or even better http://forums.lavag.org/LAVA-Premium-Membership-t2449.html' target="_blank">become premium members :thumbup: ). Maybe we need a "Send Invitation" button... Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.