操作系统_实验报告_Lab4

实 验 报 告
学生姓名 黄东 学号 16281255 指导老师 何永忠
一、 实验名称:
实验五:页面置换算法
二、 实验环境
Windows 7 旗舰版,VC 6.0
三、 实验内容:

  1. 实验设计
    1.1 概要设计
    1.2 详细设计
  2. 实验实现
    2.1 生成随机访问序列
    2.2 最佳置换算法
    2.3 先进先出置换算法
    2.4 最近最久未使用置换算法
    2.5 改进型clock置换算法
    2.6 页面缓冲置换算法
  3. 实验分析
    四、 实验过程:
  4. 实验设计
    1.1 概要设计
    由于分区式管理尽管实现方式较为简单,但存在着严重的碎片问题使得内存的利用率不高。再者,分区式管理时,由于各作业或进程对应于不同的分区以及在分区内各作业或进程连续存放,进程的大小或内存可用空间的限制。而且分区式管理也不利于程序段和数据段的共享。页式管理正是为了减少碎片以及为了只在内存存放那些反复执行或即将执行的程序段与数据部分,而把那些不经常执行的程序段和数据存放于外存待执行时调入,以提高内存利用率而提出来的页式管理有动态页式管理和静态页式管理之分,动态页式管理是在静态页式管理的基础上发展起来的。请求页式管理属于动态页式管理中的一种,它的地址变换过程与静态页式管理时的相同,也是通过页表查出相应的页面号,由页面号与页内相对地址相加而得到实际物理地址。有关的地址变换部分是由硬件自动完成的。当硬件变换机构发现所要求的页不在内存时,产生缺页中断信号,由中断处理程序做出相应的处理。中断处理程序是由软件实现的。除了在没有空闲页面时要按照置换算法选择出被淘汰页面之外,还要从外存读入所需要的虚页。这个过程要启动相应的外存和涉及到文件系统。因此,请求页式管理是一个十分复杂的过程,内存利用率的提高是以牺牲系统开销的代价换来的。这里用到了置换算法。它是在内存中没有空闲页面时被调用。目的是选出一个被淘汰的页面。如果内存中有足够的空闲页面存放所调入的页,则不必使用置换算法。把内存和外存统一管理的真正目的是把那些被访问概率非常高的页存放在内存中。因此,置换算法应该置换那些被访问概率低的页,将它们移出内存。
    1.2 详细设计
    在这里插入图片描述
    图1.2 整体结果图
  5. 实验实现
    2.1 生成随机访问序列
    在这里插入图片描述
    图2.1.1 生成序列函数
    在这里插入图片描述
    图2.1.2 生成随机序列
    2.2 最佳置换算法
    在这里插入图片描述
    图2.2.1 最佳置换算法
    在这里插入图片描述
    图2.2.2 OPT演示结果
    2.3 先进先出置换算法
    在这里插入图片描述
    图2.3.1 FIFO算法
    在这里插入图片描述
    图2.3.2 FIFO演示结果
    2.4 最近最久未使用置换算法
    在这里插入图片描述
    图2.4.1 LRU算法

在这里插入图片描述
图2.4.2 LRU演示结果
2.5 改进型clock置换算法
在这里插入图片描述
图2.5.1 CLOCK算法
在这里插入图片描述
图2.5.2 CLOCK演示结果
2.6 页面缓冲置换算法
在这里插入图片描述
图2.6.1 PBA算法
在这里插入图片描述
图2.6.2 PBA演示结果
3. 实验分析
通过设置不同的访问序列、不同的虚拟内存尺寸可以发现,在这五种页面置换算法中,opt最佳置换算法确实是最好的,在大多数情况下其缺页率都是最少的,但从时间开销上而言,opt的时间开销比较大,不出意外,先进先出算法是时间开销最小的,但也因此,其缺页率也比较高。lru算法同opt差不多,一个是往前看,一个是往后看,因此lru也是缺页率低时间开销大。而对于改进clock置换算法,由于他要对内存页面进行多次扫描,因此开销比较大。对于页面缓冲算法pab,由于其可以一起将所有已修改页面写回磁盘,因此显著减少了磁盘I/O操作次数,降低了开销。
五、 总结反思:
这次操作系统课程设计,让我们对操作系统有了更深的认识,首先操作系统是一管理电脑硬件与软件资源的程序,同时也是计算机系统内核与基石。操作系统是一个庞大的管理控制程序,大致包括5个方面的管理功能:进程与处理机管理、作业管理、存储管理、设备管理、文件管理。我们这次课程设计的题目是页面置换算法,是属于存储器管理。
在进程运行过程中,若其访问的页面不在内存而需把它们调入内存,但内存以无空闲空间时,为了保证该进程能正常的运行,系统必须从内存中调出一页程序或数据送磁盘的兑换区中,但应将哪个页面调出,需根据一定的算法来确定。通常,把选择换成页面的算法称为页面置换算法。但是在编写代码进行实际完成仍有较大不理解地方,需要参照学习其他材料。
本博客若由于排版不当,不便于观看,请下载Word报告查看:
GitHub:https://github.com/16281255/Operating-system-Lab/tree/master/实验五
参考文章:
【1】https://blog.csdn.net/AaricYang/article/details/72861566

【2】https://blog.csdn.net/qq_40743144/article/details/90578302

Y86 Tools (Student Distribution) Copyright (c) 2002, R. Bryant and D. O Hallaron, All rights reserved. May not be used, modified, or copied without permission. This directory contains the student distribution of the Y86 tools. It is a proper subset of the master distribution, minus the solution files found in the master distribution. yas Y86 assembler yis Y86 instruction (ISA) simulator hcl2c HCL to C translator ssim SEQ simulator ssim+ SEQ+ simulator psim PIPE simulator y86-code/ Examples programs and and benchmark testing scripts ptest/ Scripts for detailed automated regression testing 1. Building the Y86 tools The Y86 simulators can be configured to support TTY and GUI interfaces. A simulator running in TTY mode prints all information about its run-time behavior on the terminal. Hard to understand what s going on, but useful for automated testing, and doesn t require any special installation features. A simulator running in GUI mode uses a fancy graphical user interface. Nice for visualizing and debugging, but requires installation of Tcl/Tk on your system. To build the Y86 tools, perform the following steps: NOTE: If your instructor prepared this distribution for you, then you can skip Step 1 and proceed directly to Step 2. The Makefile will already have the proper values for GUIMODE, TKLIBS, and TKINC for your system. Step 1. Decide whether you want the TTY or GUI form of the simulators, and then modify ./Makefile in this directory accordingly. (The changes you make to the variables in this Makefile will override the values already assigned in the Makefiles in the seq and pipe directories.) Building the GUI simulators: If you have Tcl/Tk installed on your system, then you can build the GUI form by initializing the GUIMODE, TKLIBS, and TKINC variables, as appropriate for your system. (The default values work for Linux systems.) Assigning GUIMODE=-DHAS_GUI causes the necessary GUI support code in the simulator sources to be included. The TKLIBS variable tells gcc where to look for the libtcl.so and libtk.so libraries. And the TKINC variable tells gcc where to find the tcl.h and tk.h header files. Building the TTY simulators: If you don t have Tcl/Tk installed on your system, then build the TTY form by commenting out all three of these variables (GUIMODE, TKLIBS, and TKINC) in the Makefile. Step 2: Once you ve modified the Makefile to build either the GUI or TTY form, then you can construct the entire set of Y86 tools by typing unix> make clean; make 2. Files Makefile Builds the Y86 tools README This file misc/ Source files for the Y86 assembler yas, the Y86 instruction simulator yis, and the isa.c file that is used by the -t option of the processor simulators to check the results against the ISA simulation. seq/ Code for the SEQ and SEQ+ simulators. Contains HCL files for labs and homework problems that involve modifying SEQ. pipe/ Code for the PIPE simulator. Contains HCL files for labs and homework problems that involve modifying PIPE. y86-code/ Example .ys files from CS:APP and scripts for conducting automated benchmark teseting of the new processor designs. ptest/ Automated regression testing scripts for testing processor designs.
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值