Andries Brouwer. The Linux Kernel: Memory
In computer working techniques, memory paging is a memory management scheme that allows the bodily memory utilized by a program to be non-contiguous. This additionally helps avoid the issue of memory fragmentation and requiring compaction to reduce fragmentation. For historical causes, this method is sometimes referred to as swapping. When mixed with digital memory, it is named paged digital memory. On this scheme, the working system retrieves data from secondary storage in blocks of the same size (pages). Paging is a crucial part of digital memory implementations in trendy operating programs, using secondary storage to let programs exceed the scale of accessible bodily memory. Hardware support is critical for efficient translation of logical addresses to physical addresses. As such, paged memory functionality is usually hardwired into a CPU by means of its Memory Management Unit (MMU) or Memory Protection Unit (MPU), and separately enabled by privileged system code in the working system's kernel.
In CPUs implementing the x86 instruction set structure (ISA) for instance, the Memory Wave Protocol paging is enabled by way of the CR0 control register. Within the 1960s, swapping was an early virtual memory technique. An entire program or entire section would be "swapped out" (or "rolled out") from RAM to disk or Memory Wave drum, and another one can be swapped in (or rolled in). A swapped-out program could be current however its execution could be suspended while its RAM was in use by one other program; a program with a swapped-out section could continue running until it wanted that segment, at which level it can be suspended till the section was swapped in. A program would possibly embrace a number of overlays that occupy the identical memory at completely different occasions. RAM use. Subsequent architectures used memory segmentation, and particular person program segments turned the items exchanged between secondary storage and RAM. A section was this system's total code segment or information segment, or generally different giant data buildings. These segments had to be contiguous when resident in RAM, requiring further computation and motion to treatment fragmentation.
zhihu.com
1962), was the first system to implement memory paging. RAM as a seemingly contiguous logical handle area. When a process tries to reference a web page not presently mapped to a web page frame in RAM, the processor treats this invalid memory reference as a page fault and transfers management from the program to the operating system. 1. Decide whether a stolen web page frame nonetheless incorporates an unmodified copy of the web page; in that case, use that page frame. Load the required information into the accessible web page frame. 3. Replace the page desk to confer with the new page frame. 4. Return control to this system, transparently retrying the instruction that caused the page fault. When all page frames are in use, the operating system must choose a page frame to reuse for the web page the program now wants. If the evicted web page body was dynamically allocated by a program to hold data, or if a program modified it because it was read into RAM (in different phrases, if it has turn into "soiled"), it have to be written out to secondary storage before being freed.
If a program later references the evicted web page, another page fault occurs and the web page have to be read again into RAM. The strategy the operating system uses to pick the page frame to reuse, which is its page alternative algorithm, impacts efficiency. The working system predicts the page body least prone to be wanted soon, typically via the least lately used (LRU) algorithm or an algorithm based on the program's working set. To additional improve responsiveness, Memory Wave Protocol paging techniques might predict which pages can be wanted quickly, preemptively loading them into RAM before a program references them, and should steal page frames from pages which were unreferenced for a very long time, making them available. Some techniques clear new pages to avoid information leaks that compromise safety; some set them to set up defined or random values to aid debugging. When pure demand paging is used, pages are loaded solely when they are referenced. A program from a memory mapped file begins execution with none of its pages in RAM.