.. _virt_mem: Virtual Memory Management ================================= .. index:: virtual memory The :ref:`paged_mem` scheme gives rise to the notion of :term:`demand paging` using :term:`virtual memory`. The :ref:`virt_mem` system maintains a copy of the memory for all programs on secondary storage, such as a hard drive. In fact, many pages for a process may only reside in virtual memory. Loading only the page frames that are needed to run a program can make it faster to load a program. Some memory frames for a program may never be needed while the program runs. If a current copy of a frame of physical memory is held on disk in virtual memory, then that frame may be removed from physical memory to free up needed memory. When a process references memory that is not loaded in physical memory, the :ref:`mmu` of the CPU issues a :term:`page fault` trap. ------------------------ The tasks of the :ref:`virt_mem` system include: #. Maintaining the virtual memory with a reasonably current copy of memory. #. Keeping the page tables current. #. Responding to page faults by loading the requested memory frames into physical memory. ------------------------ The performance of a virtual memory management system depends on the total number of page faults, which depend on: .. describe:: The page replacement algorithm Select which frames are to be replaced when a page fault occurs. (:ref:`page_replace`) .. describe:: The frame allocation algorithm Decide how many frames to allocate to each process. (:ref:`frame_alloc`) ------------------------ **Contents:** .. toctree:: :maxdepth: 2 not_swapped virt_address_space page_fault page_replace frame_alloc segmented