Additional Information
Race conditions can occur when two pieces of parallel code modify the same variable - they could read the same variables's value at the same time, but then the piece of code saving its new value last would overwrite the values stored by the faster piece of code. Functional Global Variables can be used to protect such actions that modify data. Please note that all critical sections of code must be protected by a non-reentrant FGV as a whole; this ensures that only one action executes at a time, so conflicting operations can never perform in parallel.
As a
bad example, the following two parallel operations provoke a race condition, as the critical read-modify-write operations are implemented outside of the FGV:
In contract, in the following
good example the critical read-modify-write sections of code have been implemented as actions of the FGV. As the FGV's non-reentrancy setting ensure only one action executes at a time, the two calls will always execute after each other, preventing a race condition.
Find a description on how to implement an FGV in the Functional Global Variables paragraph of
Suggestions for Using Execution Systems and Priorities - LabVIEW 2018 Help.
A more detailed description of FGV's is available here:
Functional global variable (FGV) - RIO Developer Essentials Guide for Academia