5.2 Issues in multitasking

5.2.1 Special variables

Any variable used in aspecial declaration is called a special variable; it has dynamic scope. Every special variable has a global value, which is a value that is shared among all processes and is modifiable by any process.

A running process can dynamically bind the symbol value of a symbol that corresponds to a special variable by using Common Lisp special forms such aslet orprogv. When the scheduler needs to switch processes, it saves the value of dynamically bound special variables as part of the state information. It then performs a task called unwinding the stack, which restores the global value of any special variable that has been bound in the process. When this process is restarted, its saved state is restored, and the dynamically bound special variables regain the symbol values that they had before the switch.

If a process has not bound a special variable dynamically and then uses the Common Lisp special formsetq to modify the value of the variable, the global value is changed. The change is seen by all processes that do not have their own dynamic bindings for the variable.

In summary, when a process has dynamically bound a variable, it is as if that process has its own copy of the variable. When a process has not dynamically bound a special variable, changing the value of that variable changes its value for all processes.

The following constructs are related to the binding of global and process-specific data structures in the Multitasking Facility:


The macrolet-globally sets the value of a special variable without creating a local binding for it. It executes a series of forms and then restores the value that was in effect before the macro call.

The functionsymbol-global-value returns the global value of a special variable, even if that special variable has been dynamically bound by the current process. The functionsymbol-process-value returns the value of a special variable in a given process. If the variable is dynamically bound in that process, the dynamic value is returned; otherwise, the global value is returned.

The functionsymbol-process-boundp determines if a special variable has a value in a given process. The functionsymbol-global-boundp determines if a special variable has a global value. The termboundp in these functions means "has a value"; it does not imply the same type of binding that is performed bylet.

The functionsymbol-dynamically-boundp determines if a special variable is dynamically bound by a process.

The Advanced User's Guide - 9 SEP 1996

Generated with Harlequin WebMaker