Using Global Variables
A global variable is a variable with a global scope. The set of global variables are
known as the global environments or global state. Global variables are used to pass
information between sections of codes that do not share the same caller/callee relations
like threads and signal handlers. Without a proper locking code using the global variables
will not be thread-safe except for read only values.
For programs, it is best to put your global variable declarations at the
top/beginning. This way, you can see, in one place, the names of variables that will be
referenced across procedure boundaries.
Here is a list of the attributes of global variables.