操作系统内存储器空间的管理的实验报告.doc_第1页
操作系统内存储器空间的管理的实验报告.doc_第2页
操作系统内存储器空间的管理的实验报告.doc_第3页
操作系统内存储器空间的管理的实验报告.doc_第4页
操作系统内存储器空间的管理的实验报告.doc_第5页
已阅读5页,还剩10页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

安徽师范大学 学院实验报告专业名称 软件工程实 验 室 2#201实验课程 操作系统实验实验名称 内存储器空间的管理姓 名 学 号 同组人员 实验日期 2013/6/7注:实验报告应包含(实验目的,实验原理,主要仪器设备和材料,实验过程和步骤,实验原始数据记录和处理,实验结果和分析,成绩评定)等七项内容。具体内容可根据专业特点和实验性质略作调整,页面不够可附页。一、实验目的:一个好的计算机系统不仅要有一个足够容量的、存取速度高的、稳定可靠的主存储器,而且要能合理地分配和使用这些存储空间。当用户提出申请存储器空间时,存储管理必须根据申请者的要求,按一定的策略分析主存空间的使用情况,找出足够的空闲区域分配给申请者。当作业撤离或主动归还主存资源时,则存储管理要收回作业占用的主存空间或归还部分主存空间。主存的分配和回收的实现虽与主存储器的管理方式有关的,通过本实验帮助学生理解在不同的存储管理方式下应怎样实现主存空间的分配和回收。二、实验内容利用高级语言,实现存储分配算法,开发一个存储管理的模拟程序,对内存空间的管理和分配。内存空间的管理可采用固定分区管理方式,可变分区管理方式,页式存储管理,段式存储管理等方案。三、实验环境1 PC微机。2Windows 操作系统。3C/C+/VB开发集成环境。四、实验源程序代码第一题:#include#includeusing namespace std;#define m_STAY false;#define m_free true;static int i=6,m_s;int program100,pro_nub=4;int a100;typedef structbool state;int startplace;int thelength;string name;Th_table;bool checkisOK(Th_table *Trantables,Th_table s);void display(Th_table *Trantables);int numb(Th_table *T);int numb(Th_table *T)int sum=0;for(int j=0;ji;j+)if(!Tj.state )sum+;return sum;void display(Th_table *Trantables)int m,p1=1,p2=1;for (m=0;mi;m+)if (!Trantablesm.state)if(m!=0)cout第p1个作业的信息:endl;cout第p1个作业的名字:;coutp1作业endl;cout第p1个作业的开始地址:;coutTrantablesm.startplaceKendl;cout第p1个作业的长度:Trantablesm.thelengthendl;cout-endl;p1+;elsecout操作系统的信息:endl;cout操作系统的开始地址:;coutTrantablesm.startplaceKendl;cout操作系统的长度:Trantablesm.thelengthendl;cout-endl;elsecout第p2个空闲区信息:endl;cout第p2个空闲区的名字:p2空闲区endl;cout第p2个空闲区的开始地址:Trantablesm.startplaceKendl;cout第p2个空闲区的长度:Trantablesm.thelengthKendl;cout-endl;p2+;bool checkisOK(Th_table *Trantables,Th_table s)int m;for( m=0;m=s.thelength&Trantablesm.state)m_s=m;return true;if (m=6) return false;int main()int mbs,g=1,j;char s=0;/t;Th_table Trantables100;T=操作系统;Trantables0.startplace=0;Trantables0.state=m_STAY;Trantables0.thelength=5;program0=0;T=作业1;Trantables1.startplace=5;Trantables1.state=m_STAY;Trantables1.thelength=5;program1=1;T=作业3;Trantables2.startplace=10;Trantables2.state=m_STAY;Trantables2.thelength=4;program3=2;T=空闲区;Trantables3.startplace=14;Trantables3.state=m_free;Trantables3.thelength=12;T=作业2;Trantables4.startplace=26;Trantables4.state=m_STAY;Trantables4.thelength=6;program2=4;T=空闲区;Trantables5.startplace=32;Trantables5.state=m_free;Trantables5.thelength=96; coutttt*endl;coutttt| |endl;coutttt| 1 添 加 进 程 |endl;coutttt| |endl;coutttt| 2 结 束 |endl;coutttt| |endl;coutttt| 3 显 示 所 有 进 程 |endl;coutttt| |endl;coutttt| 4 要 求 进 程 结 束 |endl;coutttt| |endl;coutttt*endl;coutmbs;switch (mbs)case 1:coutTrantablesi.thelength;coutk!endl;if (checkisOK(Trantables,Trantablesi)cout进程申请成功!endl;programpro_nub=i;T=作业.;Trantablesi.state=m_STAY;Trantablesi.startplace=Trantablesm_s.startplace;Trantablesm_s.startplace+=Trantablesi.thelength;Trantablesm_s.thelength-=Trantablesi.thelength;i+;pro_nub+;elsecout不成功!重新输入endl;break;case 2: g=0;break;case 3:display(Trantables);break;case 4:cout请输入程序结束的次序:endl;for( j=0;jaj;for(j=0;jpro_nub;j+)for(int g=0;gi;g+)if(Trantablesg.state)if(Trantablesg.startplace=Trantablesaj.startplace+Trantablesai.thelength)Trantablesg.startplace-=Trantablesaj.thelength;Trantablesg.thelength+=Trantablesaj.thelength;Trantablesaj.state=m_free;Trantablesaj.thelength=0;cout删除后内存状况为:;display(Trantables);if(Trantablesaj.startplace=Trantablesg.startplace+Trantablesg.thelength)Trantablesg.thelength+=Trantablesaj.thelength;Trantablesaj.state=m_free;Trantablesaj.thelength=0; break;return 0;第二题:#includeusing namespace std;int pro88;int analysis(int L,int R)if(proLR=0)proLR=1;return 1;else return 0;void display()int m,n;for(m=0;m8;m+)for(n=0;n8;n+)coutpromn ;coutendl;void init()pro00=1;pro01=1;pro04=1;pro05=1;pro06=1;pro11=1;pro13=1;pro15=1;pro30=1;pro37=1;cout初始化的结果是:endl;display();int main()bool h=1;int grom;int m_L,m_R,income;init();coutttt*endl;coutttt| |endl;coutttt| 1 申 请 |endl;coutttt| |endl;coutttt| 2 退 出 |endl;coutttt| |endl;coutttt| 3 显 示 |endl;coutttt| |endl;coutttt| |endl;coutttt*endl;coutgrom;switch(grom)case 1:coutincome;m_L=income/8

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论