Code Paging Overview

Overview of demand paging when applied to code paging.

Purpose

Demand paging is a technique where memory appears to application programs to be present in RAM, but may in fact be stored on some external media and transparently loaded into RAM when needed. Demand paging trades off increased available RAM against decreased performance, increased media wear and increased power usage. More RAM is made available by loading pages only on demand, but a cost is incurred every time a page is loaded.

Demand paging is used to reduce the amount of RAM that needs to be shipped with a device and so reduce its cost.

For the code paging type of demand paging, the executable is stored in a ROM. Since the memory locations that will be pointed to cannot be determined ahead of time, the pointers in the executable have to be modified after the page-in process. This process is known as 'relocation' and 'fix-up'. It is usually done by loader.

Description

The executable is in a ROM and so has to be loaded into RAM before it can be executed. When the required part of the executable is not present in RAM, then a paging fault is generated which starts the paging in process of specifying which part of the ROM is to be paged-in along with which RAM page is to be used.

The above process (in very simple terms) describes how ROM paging works. With code paging, there is the added complication that the executable is not execute in place (it is probably stored via the use of an operating system e.g. ROFS) and so when it is paged in any pointers in the page will not point to any valid location. Hence a new step has to be carried out that modifies the pointers in the new page so that will point to meaningful locations once they are RAM. This process is known as 'relocation' and 'fix-up'. It is usually done by loader.

Components

These are the main components of code demand paging:

  • Rom image - The executable is stored in a ROM.

  • RAM - Where the executable will be executed.

  • Paging Fault Handler - To detect that a page-in process is required and to carry it out.

  • Loader - This usually does the 'relocation' and 'fix-up' process after the 'page-in' process.

Using ROM Paging

Which type of paging is used and for which area of memory is first specified the oby and mmp files and finally build by using specific parameters in the buildrom utility.