memory map

    Note: This article is excerpted from "In-depth Understanding of Computer Operating Systems" Chapter 9 - Virtual Memory.

    Linux initializes the contents of a virtual memory area by associating it with an object on disk, a process called memory mapping. A virtual memory area can be mapped to one of two types of objects:
    1. Ordinary files in unix systems: An area can be mapped to a contiguous part of an ordinary disk file, such as an executable object file. The file area is divided into page-sized slices, each slice containing the initial contents of a virtual page. Because paging occurs on demand, these virtual pages are not actually swapped into physical memory until the CPU first references the page. If the area is larger than the file area, the remainder of the area is filled with zeros.
    2. Anonymous file: An area can also be mapped to an anonymous file. An anonymous file is created by the kernel and contains all binary zeros. The first time the CPU references a virtual page in such an area, the kernel finds a suitable victim page in physical memory, swaps the page out if the page has been modified, overwrites the victim page with binary zeros and updates the page table, marking the page as resident in memory. Note that there is no actual data transfer between disk and storage. For this reason, pages in regions mapped to anonymous files are sometimes called pages requesting binary zeros.

    In either case, once a virtual page is initialized, it is swapped between a special swap file maintained by the kernel. The swap file is also called swap space or swap area. It is important to realize that at any time, swap space limits the total number of virtual pages allocated by the currently running process.

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326629007&siteId=291194637
map