CAS real-valued function CAS real-valued function Syntax CAS (variable, test_value, new_value) Function This function compares a real variable to a test value, and conditionally sets a new value as one indivisible operation. Usage Considerations The eV+ system does not enforce any protection scheme for global variables that are shared by multiple program tasks. It is the programmer's responsibility to keep track of the usage of such global variables. The CAS real-valued function (or the similar TAS function) can be used to implement logical interlocks on access to shared variables.
This function can also be used to work around a restriction on the simultaneous access of global arrays by multiple program tasks — program execution can fail if two or more tasks attempt to increase the size of an array at the same time. For a detailed description of this, see the "Global Array Access Restriction" section of the information about Arrays in the eV+ Language User's Guide . Parameters variable Name of the real-valued variable to be tested and assigned the new value given. test_value Real value, variable, or expression that defines the comparison value. new_value Real value, variable, or expression that defines the new value to be assigned to the specified variable.
Details If the variable is equal to the test value, the new value is stored in the variable. Otherwise the variable is not modified. The original value of the variable is returned as the function value. The compare and set-new-value operations occur with interrupts locked so that the operation is indivisible. This function provides a way for setting semaphores between tasks, similar to the TAS real-valued function. See the description of that function for more information — use of the CAS function is similar. eV+Language Reference Guide, v2.x, 18319-000 Rev A Page 116