页面置换课程学习资料
合集下载
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
For user 1
for user 1
valid-invalid 0 A frame bit
1B
6v
2D
i
2v
3E
7v
logical memory page table
For user 2
for user 2
0 monitor 1 2D 3H 4 load M 5J 6A 7E源自physical memory
虚拟内存管理
越界中断
开始(程序请求访问一页) 页号>页表长度? CPU检索快表
页表项是否在快表中? 访问页表
页是否在内存中? 修改快表
修改访问位和修改位 形成物理地址
地址变换结束
保留CPU现场 从外存中找到缺页
内存满否? 选择一页换出 该页是否被修改? 将该页写回外存 CPU从外存读缺页 启动I/O硬件 将一页从外存换入内存
modified pages are written to disk(修改(脏)位来防止页面转移过 多—只有被修改的页面才写入磁盘). ➢ Page replacement completes separation between logical memory and physical memory – large virtual memory can be provided on a smaller physical memory页置换实现了逻辑内存和物理内存的划 分—在一个较小的物理内存基础之上可以提供一个大的虚拟内存.
B M
OS has several options:
➢ Terminate the process 终止用户进程 ➢ Swap out a process, freeing all its frames, and reducing the degree of
multiprogramming 交换进程,释放其所有帧,降低多道程序的度 ➢ Page replacement 页面置换
西安交通大学
软件学院
操作系统原理
Operating System Principle
田丽华
9-3 页面置换
What happens if there is no free frame?
valid-invalid 0 H frame bit
1 load M PC
2J
3v 4v
5v
3M
i
logical memory page table
➢ Page replacement – find some page in memory, but not really in use, swap it out(页置换—找到内存中并没有真正使用的一些页,换出).
Page Replacement
frame valid-invalid bit
change 0 i 2 to invalid
Basic Page Replacement
➢ Find the location of the desired page on disk ➢ Find a free frame:
- If there is a free frame, use it - If there is no free frame, use a page replacement algorithm to select a
fv
4
f victim
reset page
page table table for
new page
swap out victim page 1
3 swap desired page in
physical memory
Page Replacement
➢ 如果没有空闲帧,需要两个页面传输,一个换出,一个换入。 ➢ 可以通过修改位来降低额外开销。 ➢ Use modify (dirty) bit to reduce overhead of page transfers – only
修改页表
victim frame - write the victim page to the disk, change the page and frame tables ➢ Bring the desired page into the (newly) free frame; update the page and frame tables ➢ Restart the user process