Execute in place

来源:互联网 发布:帧数测试软件fraps 编辑:程序博客网 时间:2024/05/16 06:13

From Wikipedia, the free encyclopedia

In computer science, execute in place (XIP) is a method of executing programs directly from long term storage rather than copying it into RAM. It is an extension of using shared memory to reduce the total amount of memory required.

Its general effect is that the program text consumes no writablememory, saving it for dynamic data, and that all instances of theprogram are run from a single copy.

For this to work, several criteria have to be met:

  • The storage must provide a similar interface to the CPU as regular memory (or an adaptive layer must be present),
  • This interface must provide sufficiently fast read operations with a random access pattern,
  • The file system, if one is used, needs to expose appropriate mapping functions,
  • The program must either be linked to be aware of the address the storage appears at in the system, or must be position-independent,
  • The program must not modify data within the loaded image.

The storage requirements are usually met by using NOR flash memory,which can be addressed as individual words for read operations,although it is a bit slower than normal system RAM in most setups.

Typically, the first stage boot loader is an XIP program that islinked to run at the address at which the flash chip(s) are mapped atpower-up and contains a minimal program to set up the system RAM (whichdepends on the components used on the individual boards and cannot begeneralized enough so that the proper sequence could be embedded intothe processor hardware) and then loads the second stage bootloader orthe OS kernel into RAM.

During this initialization, no writable memory is available, so allcomputations have to be performed within the processor registers. Forthis reason, first stage boot loaders tend to be written in assemblerlanguage and only do the minimum to provide a normal executionenvironment for the next program.

For a kernel or bootloader, address spacegenerally is assigned internally, so in order to use XIP for them, itis sufficient to instruct the linker to place unmodifiable andmodifiable data in different address ranges and provide a mechanism forthe modifiable data to be copied to writable memory before any code isrun that assumes that data can be accessed normally. This can be doneas part of the previous stage, or within a small code segment at thebeginning of the program.

If address space is assigned externally, such as in an application program that is run on a system that does not provide virtual memory,the compiler needs to access all modifiable data by adding an offset toa pointer to a private copy of the data area. In this case, theexternal loader is responsible for setting up the instance specificmemory areas.

XIP places requirements on file systems that are often difficult tomeet. The entire file must be stored within consecutive bytes and maynot be fragmented, while flash based file systems often aim todistribute data into sectors of the flash chip that have the leasterase cycles and even out the wear on the chip, prolonging its lifetime.

All these complications and the speed tradeoff mean that XIP isgenerally only used for first stage bootloaders and when memory isreally tight.

References

  1. Wilshire, Phil. "eXecute In Place (XIP) overview", uCdot, August 28, 2002. Accessed September 25, 2007.

See also

  • Comparison of file systems
原创粉丝点击