The stack is that part of the address space allocated at run time to accommodate the information needed by the procedure call mechanism, procedure call arguments, and automatic variables and arrays. The size of the stack varies at run time whenever a procedure is entered or exited. On some systems the stack begins at a fixed address near the top of virtual memory and grows toward lower addresses, while on others it begins at an address in the middle of virtual memory (to allow space for heap allocation), and grows toward higher numbered addresses. Special care is taken to detect if the stack resides in the data area (for example, if a user-level threads package is in use by the program) and to locate all stack frames successfully if in this case. In any case, the stack can be written to a file provided only that one knows its beginning and ending addresses. Restoring the stack requires a bit more of a trick. The problem is that if the saved stack information were to overwrite the call frame of the procedure doing the restart, not only its local variables but also all information regarding what to do at the conclusion of this procedure would be lost. To avoid this, we use a pre-defined area in the data space as a temporary stack when executing that part of the restart code which restores the stack.