4.2 Global Variables

In UNIX with very few exceptions, the declarations for global variables have been all gathered into the set of “h” files. The exceptions are:

(a)

the static variable “p” (2180) declared in “swtch” which is stored globally, but is accessible only from within the procedure “swtch” (Actually “p” is a very popular name for local variables in UNIX.);

(b)

a number of variables such as “swbuf” (4721) which are referenced only by procedures within a single file, and are declared at the beginning of that file.

Global variables may be declared separately within each file in which they are referenced. It is then the job of the loader, which links the compiled versions of the program files together to match up the different declarations for the same variable.