A page, memory page, or virtual page is a fixed-length contiguous block of virtual memory, described by a single entry in the page table. It is the smallest unit of data for memory management in a virtual memory operating system. Similarly, a page frame is the smallest fixed-length contiguous block of physical memory into which memory pages are mapped by the operating system.[1][2][3]

A transfer of pages between main memory and an auxiliary store, such as a hard disk drive, is referred to as paging or swapping.

https://en.wikipedia.org/wiki/Page_(computer_memory)

pagememory page, or virtual page is a fixed-length contiguous block of virtual memory, described by a single entry in the page table. It is the smallest unit of data for memory management in a virtual memory operating system. Similarly, a page frame is the smallest fixed-length contiguous block of physical memory into which memory pages are mapped by the operating system.[1][2][3]

A transfer of pages between main memory and an auxiliary store, such as a hard disk drive, is referred to as paging or swapping.[4]

  1. #include <stdio.h>
  2. #include <unistd.h> /* sysconf(3) */
  3.  
  4. int main(void)
  5. {
  6. printf("The page size for this system is %ld bytes.\n",
  7. sysconf(_SC_PAGESIZE)); /* _SC_PAGE_SIZE is OK too. */
  8.  
  9. return 0;
  10. }

  

内存分段(英语:Memory segmentation),一种电脑内存的管理技术,它将电脑的主内存分成许多区段(segment或sections)。当处理器要进行内存定址时,会使用一个数值,这个数值包括了某个区段,以及偏移量(offset)。一个程式的目的档(Object file)中也会使用区段,让它们可以链接成执行档,并载入内存中执行。

Memory segmentation is a computer (primarymemory management technique of division of a computer's primary memory into segments or sections. In a computer system using segmentation, a reference to a memory location includes a value that identifies a segment and an offset (memory location) within that segment. Segments or sections are also used in object files of compiled programs when they are linked together into a program image and when the image is loaded into memory.

Segments usually correspond to natural divisions of a program such as individual routines or data tables so segmentation is generally more visible to the programmer than paging alone.[1] Different segments may be created for different program modules, or for different classes of memory usage such as code and data segments. Certain segments may be shared between programs.[1]

Segmentation was originally invented as a method by which system software could isolate different software processes (tasks) and data they are using. It was intended to increase reliability of the systems running multiple processes simultaneously.[2] In a x86-64 architecture it is considered legacy and most x86-64-based modern system software don't use memory segmentation. Instead they handle programs and their data by utilizing memory-paging which also serves as a way of memory protection. However most x86-64 implementations still support it for backward compatibility reasons.[2] Moreover, segmentation is more of user's end of memory management scheme.[3]

https://zh.wikipedia.org/wiki/分頁表

在操作系统中使用虚拟内存,每个进程会认为使用一块大的连续的内存。事实上,每个进程的内存散布在物理内存的不同区域。或者可能被调出到备份存储中(一般在硬盘)。当一个进程请求自己的内存,操作系统负责把程序生成的虚拟地址,映射到实际存储的物理内存上。操作系统在分页表中存储虚拟地址到物理地址的映射。每个映射被称为分页表项(page table entry,PTE)。

The CPU's memory management unit (MMU) stores a cache of recently used mappings from the operating system's page table. This is called the translation lookaside buffer (TLB), which is an associative cache.[3]

When a virtual address needs to be translated into a physical address, the TLB is searched first. If a match is found (a TLB hit), the physical address is returned and memory access can continue. However, if there is no match (called a TLB miss), the memory management unit, or the operating system TLB miss handler, will typically look up the address mapping in the page table to see whether a mapping exists (a page walk). If one exists, it is written back to the TLB (this must be done, as the hardware accesses memory through the TLB in a virtual memory system), and the faulting instruction is restarted (this may happen in parallel as well). This subsequent translation will find a TLB hit, and the memory access will continue.

The page table lookup may fail for two reasons:

  • The lookup may fail if there is no translation available for the virtual address, meaning that virtual address is invalid. This will typically occur because of a programming error, and the operating system must take some action to deal with the problem. On modern operating systems, it will cause a segmentation fault signal being sent to the offending program.
  • The lookup may also fail if the page is currently not resident in physical memory. This will occur if the requested page has been moved out of physical memory to make room for another page. In this case the page is paged out to a secondary store located on a medium such as a hard disk drive (this secondary store, or "backing store", is often called a "swap partition" if it is a disk partition, or a swap file, "swapfile" or "page file" if it is a file). When this happens the page needs to be taken from disk and put back into physical memory. A similar mechanism is used for memory-mapped files, which are mapped to virtual memory and loaded to physical memory on demand.

When physical memory is not full this is a simple operation; the page is written back into physical memory, the page table and TLB are updated, and the instruction is restarted. However, when physical memory is full, one or more pages in physical memory will need to be paged out to make room for the requested page. The page table needs to be updated to mark that the pages that were previously in physical memory are no longer there, and to mark that the page that was on disk is now in physical memory. The TLB also needs to be updated, including removal of the paged-out page from it, and the instruction restarted. Which page to page out is the subject of page replacement algorithms.

CPU的内存管理单元(memory management unit MMU)存储最近用过的映射缓存,来自操作系统分页表。被称为转译后备缓冲器(translation lookaside buffer, TLB)。TLB是一个索引缓存。

当需要将虚拟地址转换为物理地址时,首先搜索TLB。如果找到匹配(TLB命中),则返回物理地址并继续存储器访问。然而,如果没有匹配(称为TLB未命中),则存储器管理单元或操作系统TLB未命中处理器通常会查找页表中的地址映射以查看是否存在映射(页面遍历)。如果存在,则将其写回TLB(这必须完成,因为硬件通过虚拟存储器系统中的TLB访问存储器),并且重启错误指令(这也可以并行发生)。此后续转换将找到TLB命中,并且内存访问将继续。

转换失败

有两种原因导致分页表查找失败。第一种,如果该地址没有可用的转换,这意味该虚拟地址的存储器访问是无效的。这通常是程序错误导致,操作系统需要处理这个问题。现代操作系统会发送一个段错误信号给出错程序。

当物理内存中不存在这个页,也会引起分页表查找失败。如果请求的页面被调出物理内存,给其他页腾出空间,会引起这个错误。这种情况下,页被分配到存储在介质上的辅助存储,例如硬盘。(这种辅助存储,或叫备用存储,如果是一个硬盘分区或者交换文件, 经常称之为交换分区,如果是文件,叫做分区文件或页文件。)这时候,分页需要从硬盘放回到物理内存中,这类操作通常会导致一种称为系统抖动(thrashing)的情况,通过局部性原理(principle of locality)来预测将来可能会访问的块,避免出现系统抖动。

当物理内存没满的时候,这是一个简单操作。页被写回物理内存,页表和转换备用缓冲会更新,指令重启。然而,当物理内存已满,一个或多个页要被调、为请求的页面腾出空间时候。页表需要更新,标识出那些在物理内存被调出的页,然后标识那些从硬盘调入物理内存的页。TLB也需要更新,包括去掉调出的页,重启指令。页的调入调出请见页置换算法。

Page (computer memory) Memory segmentation Page table 虚拟地址到物理地址的转换的更多相关文章

  1. 启用PAE后虚拟地址到物理地址的转换

      34 注册:2013-10 帖子:2013 精华:34 --> [原创]启用PAE后虚拟地址到物理地址的转换 安于此生 2013-11-3 20:54 16073 由常规的两级页表转换得不到 ...

  2. X64下的虚拟地址到物理地址的转换

    https://bbs.pediy.com/thread-203391.htm   早就知道传上来排版会全乱掉,把pdf直接传上来吧 x64结构体系寻址.pdf 发现安大的关于x86启用PAE下的虚拟 ...

  3. Windows虚拟地址转物理地址(原理+源码实现,附简单小工具)

                                                                                                        ...

  4. Operating System Memory Management、Page Fault Exception、Cache Replacement Strategy Learning、LRU Algorithm

    目录 . 引言 . 页表 . 结构化内存管理 . 物理内存的管理 . SLAB分配器 . 处理器高速缓存和TLB控制 . 内存管理的概念 . 内存覆盖与内存交换 . 内存连续分配管理方式 . 内存非连 ...

  5. 在Salesforce中向Page Layout中添加Visualforce Page

    在Salesforce中可以向Object所对应的Layout中添加我们自定义的Visualforce Page. 此时的Visualforce Page与Asp.Net MVC中的Partial V ...

  6. APP-SERVICE-SDK:setStorageSync:fail;at page/near/pages/shops/shops page lifeCycleMethod onUnload function

    APP-SERVICE-SDK:setStorageSync:fail;at page/near/pages/shops/shops page lifeCycleMethod onUnload fun ...

  7. 获取列表数据时,getList 设置默认参数:getList(page = 1),点击分页及前往时,传page参数,其他使用page的默认值:1

    获取列表数据时,getList 设置默认参数:getList(page = 1),点击分页及前往时,传page参数,其他使用page的默认值:1

  8. [置顶] Linux 虚拟地址与物理地址的映射关系分析【转】

    转自:http://blog.csdn.net/ordeder/article/details/41630945 版权声明:本文为博主(http://blog.csdn.net/ordeder)原创文 ...

  9. Linux 虚拟地址与物理地址的映射关系分析【转】

    转自:http://blog.csdn.net/ordeder/article/details/41630945 版权声明:本文为博主(http://blog.csdn.net/ordeder)原创文 ...

随机推荐

  1. Centos7.3 离线环境下修改时间

    运行以下命令 1.tzselect --命令确定时区 2.timedatectl set-timezone Asia/Shanghai  --设置系统时区为上海 3.timedatectl set-n ...

  2. [leetcode]120.Triangle三角矩阵从顶到底的最小路径和

    Given a triangle, find the minimum path sum from top to bottom.Each step you may move to adjacent nu ...

  3. .NET 云原生架构师训练营(模块二 基础巩固 MongoDB 问答系统)--学习笔记

    2.5.6 MongoDB -- 问答系统 MongoDB 数据库设计 API 实现概述 MongoDB 数据库设计 设计优化 内嵌(mongo)还是引用(mysql) 数据一致性 范式:将数据分散到 ...

  4. MODBUS_RTU通信协议

    Modbus是一种串行通信协议,是Modicon公司(现在的施耐德电气Schneider Electric)于1979年为使用可编程逻辑控制器(PLC)通信而发表.Modbus已经成为工业领域通信协议 ...

  5. SQL Server批量向表中插入多行数据语句

    因自己学习测试需要,需要两个有大量不重复行的表,表中行数越多越好.手动编写SQL语句,通过循环,批量向表中插入数据,考虑到避免一致问题,设置奇偶行不同.个人水平有限,如有错误,还望指正. 语句如下: ...

  6. JavaScript 内存详解 & 分析指南

    前言 JavaScript 诞生于 1995 年,最初被设计用于网页内的表单验证. 这些年来 JavaScript 成长飞速,生态圈日益壮大,成为了最受程序员欢迎的开发语言之一.并且现在的 JavaS ...

  7. python安装whl包时出现的问题解决:is not a supported wheel on this platform

    @ 目录 一.问题 二.查找问题 三.问题解决 一.问题 1.下载一个twisted包 安装Twisted,进入https://www.lfd.uci.edu/~gohlke/pythonlibs 下 ...

  8. 70.LeetCode爬楼梯

    爬楼梯 点击标题可跳转到官网进行查看 假设你正在爬楼梯.需要 n 阶你才能到达楼顶. 每次你可以爬 1 或 2 个台阶.你有多少种不同的方法可以爬到楼顶呢? 注意:给定 n 是一个正整数. 示例 1: ...

  9. MySQL sql命令行操作数据库

    数据库命令行操作 命令行操作数据库, [if exists] 可加可不加, 命令行操作一定要加英文分号 ; 结尾 创建数据库 : create database [if not exists] 数据库 ...

  10. Unsafe Filedownload - Pikachu

    概述: 文件下载功能在很多web系统上都会出现,一般我们当点击下载链接,便会向后台发送一个下载请求,一般这个请求会包含一个需要下载的文件名称,后台在收到请求后会开始执行下载代码,将该文件名对应的文件r ...