On some architectures, SWI-Prolog allows for the creation of saved states. Currently, the C-sources define two alternative implementations for them. The old implementation (6) creates an entirely self-contained executable. It supports only the save_program/[1,2] predicates. The new implementation (7) creates a file that is read by the `base' program. This file contains the data-area of the SWI-Prolog process and optionally the Prolog- and C stacks. This implementation supports save_program/[1,2], save/[1,2] and restore/1. The state-file depends entirely on exactly the Unix program-file used to create it.
Key | Option | Type | Description |
local | -L | K-bytes | Size (Limit) of local stack |
global | -G | K-bytes | Size (Limit) of global stack |
trail | -T | K-bytes | Size (Limit) of trail stack |
argument | -A | K-bytes | Size (Limit) of argument stack |
goal | -g | atom | Initialisation goal |
toplevel | -t | atom | Prolog toplevel goal |
init_file | -f | atom | Personal initialisation file |
tty | +/--tty | on/off | Use ioctl(2) calls |
As the entire data image of the current process will be saved on the new executable it is desirable to keep this small. Notably the Prolog machine stacks should be kept small. The best way to do this is first to compile the program using the -c option. If this is not possible try to find the smallest possible stack sizes to compile the program. On machines with dynamic stack allocation the stacks are not written to file and so their size does not matter. Figure 4 shows a possible session. Note the use of `initialise', which is supposed to be a predicate of the application doing time consuming initialisation.
The resulting program can be used for incremental compilation using -c or another save_program/2.
save_program(NewProgram, [])
'.
The save/1 predicate is normally used for debugging purposes. save_program/[1,2] is the preferred way to create a new program.