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

Swapping

As well as paging, the operating system uses the swapper daemon, sched, to free assigned memory pages by copying modified process pages to the swap area.

The normal state of sched is to be asleep; when awakened, it swaps processes out or in or both, depending on the needs of the system. sched becomes active and swaps processes out when the amount of free memory in the system drops to zero. ``When the swapper (sched) and the page stealing (vhand) daemons run to release memory'' illustrates sched being run to make more pages of memory available.

sched checks for processes that are either waiting for an event to complete or that have been stopped by a signal. If a process has been in either of the two states for more than 2 seconds, sched moves it from memory to the swap area, and adds the reclaimed pages to the free list. If enough memory is still not available, and sched fails to find another process that is sleeping or stopped, it attempts to swap out processes that have been on the run queue or waiting for memory longer than two seconds. ``The swapper daemon swaps out processes'' shows how sched can swap out processes in a system.

The swapper daemon swaps out processes

sched becomes active if vhand cannot make enough pages available to satisfy the demands on physical memory. It is generally preferable for a system to page rather than swap because paging creates less disk I/O, and CPU overhead. By increasing the values of GPGSLO and GPGSHI, a system will start to page memory earlier and is less likely to start swapping suddenly. However, the demands on memory may be such that swapping is inevitable at some stage. See ``Tuning memory-bound systems'' for more details of how to tune this behavior.

sched does not only swap out processes. As is the case for paging activity, swapping between physical memory and the swap area occurs in both directions. sched will swap a process in if it has a high enough priority to run.

The operating system only allocates swap space to a process when it swaps out the process. When it swaps a process back in to continue running, it retains the swap space allocation for possible future use. It only frees this when the process completes.


Next topic: Viewing physical memory usage
Previous topic: Page faults

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