DOC HOME SITE MAP MAN PAGES GNU INFO SEARCH PRINT BOOK
 
Tuning memory resources

Paging

Paging is the process by which the contents of physical memory are moved both to and from swap areas and filesystems. Paging out releases infrequently accessed memory for use by other processes. Paging in brings data or text into memory that a process needs to continue running.

At every clock tick, the kernel checks to see if the number of pages on the free list is below the number specified by the GPGSLO kernel parameter. If so, vhand, the page stealing daemon, becomes active and begins copying modified data and stack pages to the swap area, starting with least recently used pages. Each page placed on the free list then becomes available for use by other processes. Pages written out to swap must be read back into physical memory when the process needs them again.

Program text and unmodified data pages are added to the free list. Copying them to swap serves no purpose because they can be read directly from a filesystem.

vhand remains active until the number of pages on the free list rises above the number specified by the GPGSHI kernel parameter. Both GPGSLO and GPGSHI are tunable; guidelines on setting values other than the system defaults are given in ``Tuning memory-bound systems''. ``When the swapper (sched) and the page stealing (vhand) daemons run to release memory'' illustrates vhand being run to make GPGSHI pages of memory available.

When the swapper (sched) and the page stealing (vhand) daemons run to release memory

When a process terminates, its pages are added to the head of the free list. However, the kernel adds pages from a runnable process to the tail of the free list in case they are required subsequently. Processes that are expanding in memory are allocated pages from the head of the free list. In this way, the free list serves both as a source of available pages and a cache of reclaimable pages.

Page faults

A page fault is a hardware event that occurs when a user process tries to access a virtual address that has no physical memory currently assigned to it. The page fault handler attempts to provide a physical page and to load it with the appropriate data. If successful, the process that received the page fault resumes at the instruction that faulted as though the page of memory was always there. Page faults are the opposite of page outs as they involve loading pages into memory rather than copying pages out of memory.

When required, the correct page can be acquired by the page fault handler in several ways:

Pages belonging to the kernel are usually not paged in or out. Kernel text and most of its associated data structures reside permanently in physical memory while the operating system is running. The only kernel memory that can be swapped or paged are the structures which store internal information about the state of individual processes. These include a process' u-area, Task State Segment (TSS), and page tables.

Next topic: Swapping
Previous topic: How the virtual memory of a process relates to physical memory and disk

© 2003 Caldera International, Inc. All rights reserved.
SCO OpenServer Release 5.0.7 -- 11 February 2003