文档介绍:Chap 10 Virtual Memory虚存
编写:王红玲
Applied Operating System Concepts
内容
Background(背景)
Demand Paging(请求页式)
Performance of Demand Paging(请求页式的性能)
Page Replacement(页置换)
Page-Replacement Algorithms(页置换算法)
Allocation of Frames (页框的分配)
Thrashing(颠簸)
Other Considerations(其他考虑)
Demand Segmentation(请求段式)
Summary(总结)
Applied Operating System Concepts
Background 背景
Virtual memory – separation of user logical memory from physical memory.(虚拟内存—物理内存和用户逻辑内存的区分)
Only part of the program needs to be in memory for execution(只有部分运行的程序需要在内存中).
Logical address space can therefore be much larger than physical address space(因此,逻辑地址空间能够比物理地址空间大).
Need to allow pages to be swapped in and out(必须允许页面能够被换入和换出).
Virtual memory can be implemented via(虚拟内存能够通过以下手段来执行):
Demand paging (请求页式)
Demand segmentation(请求段式)
Applied Operating System Concepts
Demand Paging 请求分页
Bring a page into memory only when it is needed(只有在一个页需要的时候才把它换入内存).
Less I/O needed(需要很少的I/O)
Less memory needed (需要很少的内存)
Faster response(快速响应)
More users(多用户)
Page is needed (需要页) reference to it(查阅此页)
invalid reference(无效的访问) abort(中止)
not-in-memory(不在内存) bring to memory(换入内存)
Applied Operating System Concepts
Valid-Invalid Bit 有效-无效位
With each page table entry a valid–invalid bit is associated(1 in-memory, 0 not-in-memory)(在每一个页表的表项有一个有效- 无效位相关联,1表示在内存,0表示不内存)
Initially valid–invalid but is set to 0 on all entries(在所有的表项,这个位被初始化为0).
Example of a page table snapshot(一个页表映象的例子).
During address translation, if valid–invalid bit in page table entry is 0(在地址转换中,如果页表表项位的值是0) page fault(缺页).
1
1
1
1
0
0
0
Frame #
valid-invalid bit
page table
Applied Operating System Concepts
Page Fault 缺页
If there is ever a reference to a page, first reference will trap to OS(如果有对一个页的访问,第一个访问要陷入OS) page fault(缺页)
OS looks at another table to decide(OS查看另一个表来决定):
Invalid reference(无效引用) abort(终止).
Just not in memory(仅仅不在内存).
Get empty frame(得到空的页框).
Swap page into frame(把页换入页框).
Reset tables, vali