Identifying Swapped Out Pages

As discussed in Chapter 4, a memory page is identified on the basis of a virtual address using a system of page tables to find the address of the associated page frame in RAM. This only works if the data are actually present in memory; otherwise, there is no page table entry. It must also be possible to correctly identify swapped-out pages; in other words, it must be possible to find the address of a memory page in a swap area by reference to a given virtual address.

Swapped-out pages are marked in the page table by means of a special entry whose format depends on the processor architecture used. Each system uses special coding to satisfy the particular requirements.

Common to all CPUs is that the following information is stored in the page table entry of a swapped-out page:

□ An indicator that the page has been swapped out.

□ The number of the swap area in which the page is located.

□ An offset that specifies the relevant page slot is also required to enable the page to be found within the swap area.

The kernel defines an architecture-independent format that can be derived (by the processor-specific code) from the architecture-dependent data and is used to identify pages in the swap area. The advantage of this approach is clearly that all swapping algorithms can be implemented regardless of the hardware used and need not be rewritten for each processor type. The only interface to the actual hardware are the functions for converting between architecture-specific and architecture-independent representation.

In the architecture-independent representation, the kernel must store both the identification (also referred to as type) of the swap partition and an offset within this area in order to be able to uniquely identify a page. This information is kept in a special data type called swap_entry_t, which is defined as follows:

Continue reading here: Info

Was this article helpful?

0 0