5.2 Issues in multitasking
specialdeclaration 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 as
progv. 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 form
setq 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:
let-globally symbol-global-value symbol-process-value symbol-process-boundp symbol-global-boundp symbol-dynamically-boundpThe macro
let-globallysets 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.
symbol-global-value returns the global value of a special variable, even if that special variable has been dynamically bound by the current process. The function
symbol-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.
symbol-process-boundp determines if a special variable has a value in a given process. The function
symbol-global-boundp determines if a special variable has a global value. The term
boundp in these functions means "has a value"; it does not imply the same type of binding that is performed by
symbol-dynamically-boundp determines if a special variable is dynamically bound by a process.
Generated with Harlequin WebMaker