What is a Lisp image?

Essentially, I would like to know what a Lisp image is? Is this a piece of memory containing a Lisp interpreter and one or more programs, or what?

+22
lisp common-lisp
Jan 26 '09 at 15:09
source share
3 answers

Lisp image as flushed memory

An image is usually a file. This is a Lisp system dump. It contains all the functions (often compiled for machine code), variable values, characters, etc. Lisp systems. This is a snapshot of the start of Lisp.

To create an image, start Lisp, it uses it for a while, and then deletes the image (the name of the function, which depends on the implementation).

Using Lisp Image

The next time Lisp restarts, you can use the discarded image and get the state back about where it was before. When resetting the image, you can also tell Lisp what it should do when the reset image is running. Thus, you can connect to the servers again, open the files again, etc.

To run such a Lisp system, a kernel and image are required. Sometimes Lisp can put both in one file, so the executable file contains both the kernel (with some functionality at runtime) and image data.

On a Lisp machine (a computer with the Lisp operating system), a bootloader view (FEP, Front End Processor) can load an image (called a "world") into memory and then run that image. In this case, there is no kernel, and everything that works on the computer is a Lisp image that contains all the functionality (interpreter, compiler, memory management, GC, network stack, drivers ...). This is mainly an OS in a single file.

Some Lisp systems will optimize memory before resetting the image. They can do garbage collection, order objects in memory, etc.

Why use images?

Why use images? This saves time to load things, and you can provide pre-configured Lisp systems with application code and data for users. Starting a general Lisp implementation with a saved image is usually fast - a few milliseconds on the current computer.

Since a Lisp image can contain a lot of functionality (a compiler, even a development environment, a lot of debugging information, ...), it usually has a size of several megabytes.

Using images in Lisp is very similar to what Smalltalk systems do. For example, Squeak also uses an image of the Smalltalk code and data and the runtime executable. There is a practical difference: most modern Lisp systems use compiled machine code. Thus, the image is not transferred between different processor architectures (x86, x86-64, SPARC, POWER, ARM, ...) or even operating systems.

Story

Such Lisp images have been used for a long time. For example, the SYSOUT function in BBN Lisp since 1967 has created such an image. SYSIN will read such an image at the beginning.

Examples of functions that save images

For an example, see the LispWorks save-image function or read the SBCL manual for saving basic images .

+35
Feb 25 '09 at 12:25
source share

Several language implementations use an “image” to store “everything” in the current context. This image may contain several layers of compilation abstraction (i.e., an intermediate level of parsing, an intermediate bytecode, native operating codes). Download this image will be much faster than compiling all source files. This is very similar to hibernation at the program level.

For example, if your-lisp -implementation uses an image, than you (or the compiler provider will) first boot the image belt and save it.

Then you have two options: (1) either load the lisp file every time you call lisp, or (2) load all your lisp and save the image and use that image

Hope that helps

+7
Jan 26 '09 at 15:21
source share

In general, this is part of the storage of the lisp process (that is, all functions and “lisp” data), but does not contain parts of the underlying lisp binary code. On the positive side, this gives a quick start, since there (essentially) you do not need to keep records when downloading an image, everything is simple. On the other hand, this means that any open files, sockets, and things that miss you, so saving images as a kind of check-pointing will require some implementation to make it work.

+6
Jan 27 '09 at 11:56
source share



All Articles