Global Variables

Suppose the code for each machine is counting instances of some event. You want a single count for the whole test and so each machine adds its count to a global variable. When you are executing the code for all your machines in parallel, two instances of the statement iGlobal = iGlobal + iCount could be executing in parallel. Since the instructions that implement this statement would then be interleaved, you could get erroneous results. To prevent this problem, you can declare a variable shareable. When you do so, you can use the access statement to gain exclusive access to the shared variable for the duration of the block of code following the access statement. Make variables shareable whenever the potential for conflict exists.