An overview of the system

Memory management

Memory is also managed by the kernel. A computer capable of running a multi-tasking system may have to deal with widely varying demands for memory. At some times, no users may be logged on and the only tasks running are the kernel and possibly a backup process. At other times, ten or more users may all be carrying out complex operations which demand lots of memory. The SCO OpenServer system provides ``virtual'' memory. That is, while each process ``sees'' an allocation of 4GB of memory available to it, in fact the kernel only doles out memory to a process as and when it requests it: when a process is not actually running, the kernel can swap or page the contents of its physical memory out to a swap space on disk, freeing it up temporarily for another process. The user's process refers to each unit of memory by its address (a number indicating where in the address space of the process, that is, its available memory, the unit lies), and the kernel maps from the requested address to the real memory address, which may be located somewhere else in the computer's memory or paged out to disk. Disk accesses are very slow compared with memory accesses. Consequently, a process that demands a lot of memory may spend much of its time waiting for pages of memory to be read in or written out to disk.

When the system runs low on memory, it may forcibly swap out processes that have been running for a while to make room for other processes. When memory demands exceed the memory available, it may begin to ``thrash;'' that is, the time it spends swapping processes in and out may vastly exceed the amount of time it spends running them.

The advantage of virtual memory is that, while it is not inexhaustible, it does not run out suddenly; the system does not abruptly refuse to start new processes because it is running low on memory. Thus, as the load on the system increases, its performance tends to degrade gradually. (The system may refuse to run more processes if its process table becomes full. This is extremely unlikely to happen in normal use.)

Two processes are spawned by the kernel to handle paging and swapping. Paging refers to the allocation of virtual memory. ``Pages'' of memory are mapped onto the processes' address space, and the kernel process keeps track of whether the page is physically present in the computer's memory or is present on the hard disk. Swapping is a mechanism which allows an entire process to be dumped out of memory and stored on a swap partition on the hard disk. These processes are sched and vhand, processes 0 and 2 respectively. You cannot kill these processes and you will never see executable files called sched or vhand on the filesystem because they are parts of the kernel.

Next topic: The UNIX system life cycle
Previous topic: How multi-tasking works

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