麦冬和什么相克| 麦冬有什么作用| 新生儿呛奶是什么原因引起的| 王维字什么| 什么叫肺纤维化| 宜入宅是什么意思| 4月18日什么星座| 长发公主叫什么名字| 32年婚姻是什么婚| 心脏缺血吃什么补的快| 性状是什么意思| 为什么风团会在晚上爆发| 低血糖看什么科室| 减肥吃什么主食比较好| 文艺范是什么意思| 什么是肠漏| 什么是胸推| 足下生辉是什么意思| 双恋是什么意思| 牙龈是什么| 理数是什么意思| 六味地黄丸主治什么| 手足口病挂什么科| 多潘立酮片是什么药| 牛与什么生肖最配| 河东狮吼什么意思| 低密度是什么意思| 肠胃痉挛什么症状| 眼镜是什么时候发明的| 心阴虚吃什么食物| 夜盲症吃什么| 孕妇梦见猫是什么意思| 肺与什么相表里| 花瓣是什么意思| 奉献是什么意思| 为什么会长子宫肌瘤| 琉璃色是什么颜色| 尿血吃什么药| 难怪是什么意思| SS是什么| 吃什么食物下奶快而且奶多| 夜间睡觉流口水是什么原因| 浅表性胃炎吃什么中成药最好| 曼陀罗是什么意思| 美国为什么要打伊朗| 小酌怡情什么意思| 狗与什么属相相冲| 圆明园是什么时候被烧的| 女人性冷淡是什么原因| 为什么腰疼| 长期失眠吃什么药| 大便不成形吃什么药| 关系是什么意思| 综合用地是什么性质| 乙肝恢复期是什么意思| 喝酒上脸是什么原因| 经常口臭的人是什么原因引起的| 香蕉皮擦脸有什么作用与功效| 鲁班姓什么| 鸾凤是什么意思| 血糖高一日三餐吃什么东西最适合| 吃什么食物可以降尿酸| 加德纳菌阳性是什么意思| 什么是白带| 看脚趾头挂什么科| 什么是光| 晕车喝什么饮料| 广西北海有什么好玩的地方| 34属什么| 增强抵抗力免疫力吃什么| 白花花的什么| 多元是什么意思| 被舔下面什么感觉| 19年是什么年| 马鞍皮是什么皮| 老人吃什么钙片补钙效果最好| 起风疹的原因是什么引起的| 子宫脱垂是什么症状| hpv感染吃什么药| 喝老陈皮水有什么好处| 6542是什么药| 碘伏用什么可以洗掉| 下午16点是什么时辰| 戊午五行属什么| 女生过生日送什么礼物好| 少白头是什么原因| 尉迟恭是什么生肖| 狐臭和汗臭有什么区别| 中国黄金为什么便宜| 女人月经总是提前是什么原因| 嫑怹是什么意思| 水代表什么| 臭屁什么意思| 小孩什么时候会说话| 睾丸扭转有什么症状| kw是什么单位| 寸关尺代表什么器官| 三月三日是什么星座| 一票制什么意思| 兔子的耳朵有什么作用| 八月六号是什么星座| 研讨会是什么意思| 查胆固醇挂什么科| 负荆请罪的负是什么意思| 一个火一个宣念什么| 03年是什么年| 头脑灵活是什么生肖| 1966年属什么| 两女 一杯是什么| leu是什么意思| 止痛片吃多了有什么副作用| 害怕的反义词是什么| 嘴巴发苦是什么原因造成的| 取保候审需要什么条件| 什么是周期| 占位性病变是什么意思| 褪黑素什么时候吃| 宫内囊性回声代表什么| 舌头痛吃什么药| 野生蜂蜜有什么好处和作用| 落花雨你飘摇的美丽是什么歌| 今天什么日| 心肌缺血是什么原因造成的| 6月15号是什么星座| 什么的积雪| 4c是什么| jeans是什么意思| 红豆生南国什么意思| 淋巴细胞是什么| 蛋白粉是什么| ts是什么意思| 怕金病帕金森是什么症状| 全身痒是什么病| 什么样的手相最有福气| 失眠吃什么药效果最好| 小马过河的故事告诉我们什么道理| 三净肉是什么| 三八是什么意思| 故人是什么意思| sec是什么单位| 微创人流和无痛人流有什么区别| 喝什么去湿气| 多囊是什么原因引起的| 慢性子宫颈炎是什么意思| 鱼腥草有什么作用| 为什么打喷嚏| 脂肪肝吃什么最好| 金利来属于什么档次| 一鸣惊人指什么生肖| 农历10月22日是什么星座| 春天有什么特点| co是什么| 女生月经迟迟不来是什么原因| 梦见已故朋友什么预兆| 上曼月乐环后要注意什么| 人人有的是什么生肖| 紫茉莉什么时候开花| 左手臂有痣代表什么| 宝宝照蓝光有什么副作用| 胸腺肿瘤是什么病| 身上麻是什么原因| 强身之道的强是什么意思| 骨头坏死是什么感觉| 打嗝是什么病| 黑猫警长是什么猫| 检查腰部挂什么科| 5月23是什么星座| 超度是什么意思| 挚友是指什么的朋友| 戌怎么读音是什么| 什么的童年| 什么的哭| 北肖指什么生肖| 石斛有什么功效和作用| 西梅什么时候上市| 宝宝有口臭是什么原因引起的| 老年人骨质疏松吃什么钙片好| 人流后什么叫重体力活| 药流用什么药| 什么叫积阴德| 掉头发是缺什么| 后脑勺痛什么原因引起的| 头晕是什么情况| 大自然是什么意思| 什么锅好| 荆芥俗名叫什么| 萎缩性胃炎吃什么食物好| 孕期阴道炎可以用什么药| 什么能力| 偏头痛挂什么科| 矢气是什么意思| 激光脱毛对身体有什么危害| 放低姿态是什么意思| 单抗是什么药| 翎字五行属什么| 韩红是什么民族| 支原体吃什么药| 什么远什么长| 好聚好散是什么意思| beacon什么意思| 眼睛充血用什么药| 什么样的伤口需要缝针| 一望无际是什么意思| 萨德事件是什么意思| 喝水牙疼是什么原因| 皱褶什么意思| 流年是什么意思| 千岛酱是什么味道| 上24休24是什么意思| 画皮是什么意思| 茵芙莎属于什么档次| aj是什么| 7是什么意思| 面面俱到是什么意思| 鲨鱼吃什么| 原点是什么| 芝士是什么做的| 什么药可以降尿酸| 皮下出血点是什么原因| 精囊在什么位置| 青色是什么颜色| 低gi是什么意思| 狮子住在什么地方| 农历2月份是什么星座| vana是什么牌子| 梦见涨洪水是什么兆头| 骨骼肌是什么意思| 淋巴结是什么引起的| 霉菌是什么东西| cr是什么意思| 新农合是什么| dikang是什么药| 不解什么| 吃华法林不能吃什么| 脸上长斑的原因是什么引起的| apd是什么意思| 肾结石什么症状| 色斑是什么原因引起的| 墙内开花墙外香是什么意思| 眼球发黄是什么原因| 一什么蘑菇| 香港脚是什么症状图片| 实名认证是什么意思| 胃酸烧心吃什么药| 维c什么时候吃效果最好| 唇红是什么原因| 无机磷测定是检查什么| 吃什么对牙齿有好处| 全职是什么意思| 小龙虾和什么不能一起吃| 鬼打墙什么意思| 海蜇长什么样| 痔疮嵌顿是什么意思| 头晕是什么病的征兆| 湿浊中阻是什么意思| 肠胃不好吃什么水果好| 长白班是什么意思| 优甲乐过量有什么症状| 支原体阳性是什么意思| 什么病| 五月七号是什么星座| 眼睛痒流泪是什么原因| miu是什么意思| 子宫有积液是什么原因引起的| 百度Jump to content

睡觉时身体抽搐是什么原因

From Wikipedia, the free encyclopedia
Relationship between pages addressed by virtual addresses and the pages in physical memory, within a simple address space scheme. Physical memory can contain pages belonging to many processes. Pages can be held on disk if seldom used, or if physical memory is full. In the diagram above, some pages are not in physical memory.
百度 (作者系国家社科基金重大项目“苏联科学院《俄国文学史》翻译与研究”首席专家、南京师范大学教授)

A page table is a data structure used by a virtual memory system in a computer to store mappings between virtual addresses and physical addresses. Virtual addresses are used by the program executed by the accessing process, while physical addresses are used by the hardware, or more specifically, by the random-access memory (RAM) subsystem. The page table is a key component of virtual address translation that is necessary to access data in memory. The page table is set up by the computer's operating system, and may be read and written during the virtual address translation process by the memory management unit or by low-level system software or firmware.

Role of the page table

[edit]

In operating systems that use virtual memory, every process is given the impression that it is working with large, contiguous sections of memory. Physically, the memory of each process may be dispersed across different areas of physical memory, or may have been moved (paged out) to secondary storage, typically to a hard disk drive (HDD) or solid-state drive (SSD).

When a process requests access to data in its memory, it is the responsibility of the operating system to map the virtual address provided by the process to the physical address of the actual memory where that data is stored. The page table is where mappings of virtual addresses to physical addresses are stored, with each mapping also known as a page table entry (PTE).[1][2]

The translation process

[edit]
Actions taken upon a virtual to physical address translation. Each translation is restarted if a TLB miss occurs, so that the lookup can occur correctly through hardware.

The memory management unit (MMU) inside the CPU 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.

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

Translation failures

[edit]

The page table lookup may fail, triggering a page fault, 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.

Some MMUs trigger a page fault for other reasons, whether or not the page is currently resident in physical memory and mapped into the virtual address space of a process:

  • Attempting to write when the page table has the read-only bit set causes a page fault. This is a normal part of many operating system's implementation of copy-on-write; it may also occur when a write is done to a location from which the process is allowed to read but to which it is not allowed to write, in which case a signal is delivered to the process.
  • Attempting to execute code when the page table has the NX bit (no-execute bit) set in the page table causes a page fault. This can be used by an operating system, in combination with the read-only bit, to provide a Write XOR Execute feature that stops some kinds of exploits.[3]

Frame table data

[edit]

The simplest page table systems often maintain a frame table and a page table. The frame table holds information about which frames are mapped. In more advanced systems, the frame table can also hold information about which address space a page belongs to, statistics information, or other background information.

Page table data

[edit]

The page table is an array of page table entries.

Page table entry

[edit]

Each page table entry (PTE) holds the mapping between a virtual address of a page and the address of a physical frame. There is also auxiliary information about the page such as a present bit, a dirty or modified bit, address space or process ID information, amongst others.

Secondary storage, such as a hard disk drive, can be used to augment physical memory. Pages can be paged in and out of physical memory and the disk. The present bit can indicate what pages are currently present in physical memory or are on disk, and can indicate how to treat these different pages, i.e. whether to load a page from disk and page another page in physical memory out.

The dirty bit allows for a performance optimization. A page on disk that is paged in to physical memory, then read from, and subsequently paged out again does not need to be written back to disk, since the page has not changed. However, if the page was written to after it is paged in, its dirty bit will be set, indicating that the page must be written back to the backing store. This strategy requires that the backing store retain a copy of the page after it is paged in to memory. When a dirty bit is not used, the backing store need only be as large as the instantaneous total size of all paged-out pages at any moment. When a dirty bit is used, at all times some pages will exist in both physical memory and the backing store.

In operating systems that are not single address space operating systems, address space or process ID information is necessary so the virtual memory management system knows what pages to associate to what process. Two processes may use two identical virtual addresses for different purposes. The page table must supply different virtual memory mappings for the two processes. This can be done by assigning the two processes distinct address map identifiers, or by using process IDs. Associating process IDs with virtual memory pages can also aid in selection of pages to page out, as pages associated with inactive processes, particularly processes whose code pages have been paged out, are less likely to be needed immediately than pages belonging to active processes.

As an alternative to tagging page table entries with process-unique identifiers, the page table itself may occupy a different virtual-memory page for each process so that the page table becomes a part of the process context. In such an implementation, the process's page table can be paged out whenever the process is no longer resident in memory.

Page table types

[edit]

There are several types of page tables, which are optimized for different requirements. Essentially, a bare-bones page table must store the virtual address, the physical address that is "under" this virtual address, and possibly some address space information.

Inverted page tables

[edit]

An inverted page table (IPT) is best thought of as an off-chip extension of the TLB which uses normal system RAM. Unlike a true page table, it is not necessarily able to hold all current mappings. The operating system must be prepared to handle misses, just as it would with a MIPS-style software-filled TLB.

The IPT combines a page table and a frame table into one data structure. At its core is a fixed-size table with the number of rows equal to the number of frames in memory. If there are 4,000 frames, the inverted page table has 4,000 rows. For each row there is an entry for the virtual page number (VPN), the physical page number (not the physical address), some other data and a means for creating a collision chain, as we will see later.

Searching through all entries of the core IPT structure is inefficient, and a hash table may be used to map virtual addresses (and address space/PID information if need be) to an index in the IPT - this is where the collision chain is used. This hash table is known as a hash anchor table. The hashing function is not generally optimized for coverage - raw speed is more desirable. Of course, hash tables experience collisions. Due to this chosen hashing function, we may experience a lot of collisions in usage, so for each entry in the table the VPN is provided to check if it is the searched entry or a collision.

In searching for a mapping, the hash anchor table is used. If no entry exists, a page fault occurs. Otherwise, the entry is found. Depending on the architecture, the entry may be placed in the TLB again and the memory reference is restarted, or the collision chain may be followed until it has been exhausted and a page fault occurs.

A virtual address in this schema could be split into two, the first half being a virtual page number and the second half being the offset in that page.

A major problem with this design is poor cache locality caused by the hash function. Tree-based designs avoid this by placing the page table entries for adjacent pages in adjacent locations, but an inverted page table destroys spatial locality of reference by scattering entries all over. An operating system may minimize the size of the hash table to reduce this problem, with the trade-off being an increased miss rate.

There is normally one hash table, contiguous in physical memory, shared by all processes. A per-process identifier is used to disambiguate the pages of different processes from each other. It is somewhat slow to remove the page table entries of a given process; the OS may avoid reusing per-process identifier values to delay facing this. Alternatively, per-process hash tables may be used, but they are impractical because of memory fragmentation, which requires the tables to be pre-allocated.

Inverted page tables are used for example on the PowerPC, the UltraSPARC and the IA-64 architecture.[4]

Multilevel page tables

[edit]
Two-level page table structure in x86 architecture (without PAE or PSE).
Three-level page table structure in x86 architecture (with PAE, without PSE).

The inverted page table keeps a listing of mappings installed for all frames in physical memory. However, this could be quite wasteful. Instead of doing so, we could create a page table structure that contains mappings for virtual pages. It is done by keeping several page tables that cover a certain block of virtual memory. For example, we can create smaller 1024-entry 4 KB pages that cover 4 MB of virtual memory.

This is useful since often the top-most parts and bottom-most parts of virtual memory are used in running a process - the top is often used for text and data segments while the bottom for stack, with free memory in between. The multilevel page table may keep a few of the smaller page tables to cover just the top and bottom parts of memory and create new ones only when strictly necessary.

Now, each of these smaller page tables are linked together by a master page table, effectively creating a tree data structure. There need not be only two levels, but possibly multiple ones. For example, a virtual address in this schema could be split into three parts: the index in the root page table, the index in the sub-page table, and the offset in that page.

Multilevel page tables are also referred to as "hierarchical page tables".

Virtualized page tables

[edit]

It was mentioned that creating a page table structure that contained mappings for every virtual page in the virtual address space could end up being wasteful. But, we can get around the excessive space concerns by putting the page table in virtual memory, and letting the virtual memory system manage the memory for the page table.

However, part of this linear page table structure must always stay resident in physical memory in order to prevent circular page faults and look for a key part of the page table that is not present in the page table.

Nested page tables

[edit]

Nested page tables can be implemented to increase the performance of hardware virtualization. By providing hardware support for page-table virtualization, the need to emulate is greatly reduced. For x86 virtualization the current choices are Intel's Extended Page Table feature and AMD's Rapid Virtualization Indexing feature.

See also

[edit]

References

[edit]
  1. ^ "Virtual Memory". umd.edu. Retrieved 28 September 2015.
  2. ^ "Page Table Management". kernel.org. Retrieved 28 September 2015.
  3. ^ "W^X - The Mechanism".
  4. ^ William Stallings, Operating Systems Internals and Design Principles, p. 353.

Further reading

[edit]
[edit]
知了猴什么时候出来 低筋面粉可以用什么代替 检查胆囊挂什么科 7月5日是什么星座 银行卡年费是什么意思
猪肚和什么煲汤最好 姓名字号是什么意思 凉粉是什么材料做的 腿脚肿胀是什么原因引起的 干眼症缺乏什么维生素
代偿是什么意思 捞佬是什么意思 儿童缺铁吃什么补得快 即兴表演是什么意思 沙虫是什么
国药准字号是什么意思 尿拉不出来是什么原因 为什么支气管炎咳嗽长期不好 排长是什么级别 水化是什么意思
敛财什么意思hcv7jop6ns9r.cn 什么人容易得尿毒症hcv8jop0ns6r.cn 白带清洁度lv是什么意思hcv9jop7ns3r.cn 一直吐口水是什么原因hcv8jop8ns9r.cn 皮肤发烫是什么原因hcv7jop5ns3r.cn
办理护照需要什么手续hcv8jop8ns2r.cn 优雅知性是什么意思hcv8jop4ns9r.cn 香港有什么好吃的hcv8jop6ns4r.cn 近亲为什么不能结婚wuhaiwuya.com 直肠增生性的息肉是什么意思mmeoe.com
nmol是什么单位hcv9jop5ns1r.cn nasa是什么意思hcv8jop9ns1r.cn 男属鼠的和什么属相最配hcv9jop4ns6r.cn 流鼻血是什么原因引起的hcv8jop3ns5r.cn 飞机票号是什么意思youbangsi.com
色是什么结构hcv7jop6ns3r.cn 兜底是什么意思hcv7jop5ns3r.cn 眼睛发热是什么原因hcv8jop7ns4r.cn 1997年是什么生肖hcv8jop8ns5r.cn 水瓶座后面是什么星座hcv8jop3ns9r.cn
百度