beautypg.com

Virtual memory – AMT Datasouth PAL User Manual

Page 13

background image

PAL Fundamentals

7

When PAL encounters an executable name, PAL goes to the dictionary stack to find out what to
do. PAL starts by trying to locate the name in the top-most dictionary on the dictionary stack. If it
cannot find the name, it then tries the next dictionary down on the stack. PAL continues down the
stack until it locates the name. Once PAL locates the name, it stops searching.

Since PAL stops searching when it locates the name, any entries for a given name in a dictionary
on the top of the dictionary stack will supercede an entry in a dictionary on the bottom of the stack.
As the above diagram shows, systemdict resides on the very bottom on the dictionary stack.
Therefore, any entry for a name in any other dictionary on the dictionary stack will have
precedence over the entry for that name in systemdict.

As a result, the programmer has the freedom to redefine any of the names which PAL has
predefined for performing the various PAL operations. However, redefining PAL operators only
serves to make a PAL order sequence difficult for another programmer to understand.

The dictionary stack also serves a more important purpose. It allows the PAL programmer to
define new names to which the PAL interpreter will automatically respond. The programmer can
add a new name with an associated value object to one of the dictionaries on the dictionary stack.
Later, when PAL encounters the name, it will search the dictionary stack and find the
programmer's entry.

If the programmer associates a procedure object with the name, PAL will automatically execute the
procedure. If the programmer associations an integer, string, or other data object with the name,
PAL will automatically push the data object onto the operand stack.

The programmer may not alter the contents of systemdict. However, PAL automatically provides
the programmer with the two dictionaries userdict, and globaldict. The programmer may freely
add and delete entries from these dictionaries. During initialization, PAL creates userdict and
globaldict as empty dictionaries.

PAL also provide operators which allow the programmer to push new dictionaries onto the
dictionary stack and later pop them off the stack. This allows the programmer to collect localized
definitions into separate dictionaries and then discard all the definitions by simply popping the
dictionaries from the dictionary stack.

Although PAL allows the programmer to add and delete entries within userdict and globaldict,
PAL does not allow the programmer to remove the three standard dictionaries themselves from the
dictionary stack.

2.9.

Virtual Memory

The interpreter keeps all user data objects as well as the various interpreter data structures within
the virtual memory area. PAL refers to this memory area as virtual memory because the pro-
grammer does not have direct access to this memory.

PAL dynamically manages this space for the programmer. As the programmer sends objects to the
PAL interpreter, the interpreter automatically allocates space for the objects within the virtual
memory area. When the programmer no longer requires a particular object, PAL automatically
frees the object's memory for use by other objects.

PAL will keep an object within virtual memory for as long as the programmer maintains a ref-
erence to the object. Once the programmer eliminates all references to the object, PAL auto-
matically removes the object from memory.