Overview
This project demonstrates how you can implement Functional Global Variables (FGVs) as action engines to ensure against code-breaking race conditions.
Description
Often when starting a new application, it is easy to forget to look forwards. I have often used local variables in small code without a second thought. This is all well and good if it is a small simple code that isn’t going anywhere, but what about when you want to expand it and increase functionality? You can start to come un-stuck with local variables as race conditions will creep up on you as your code expands. By using Action Engines from the start, you can save yourself time (and money) later by not having to re-work and debug a code to remove race conditions.
To ensure against code-breaking race conditions you can implement Functional Global Variables (FGVs) as action engines. (As a reminder: An FGV is a non-re-entrant sub VI which uses uninitialized shift registers to store data.) An FGV will store data for if it is kept in memory. An FGV that does anything more than reading and writing data is known as an Action Engine. Using the state machine within the FGV allows you to perform critical operations on data whilst protecting the code from race conditions.
Requirements
Steps to Implement or Execute Code
Additional Information or References
**This document has been updated to meet the current required format for the NI Code Exchange. **
Example code from the Example Code Exchange in the NI Community is licensed with the MIT license.
For more information on Action Engines see here where you will find a Nugget I wrote on the topic in 2007.
Ben