Linux操作系统实验报告存储管理试验

上传人:re****.1 文档编号:486524902 上传时间:2022-09-17 格式:DOC 页数:10 大小:307.02KB
返回 下载 相关 举报
Linux操作系统实验报告存储管理试验_第1页
第1页 / 共10页
Linux操作系统实验报告存储管理试验_第2页
第2页 / 共10页
Linux操作系统实验报告存储管理试验_第3页
第3页 / 共10页
Linux操作系统实验报告存储管理试验_第4页
第4页 / 共10页
Linux操作系统实验报告存储管理试验_第5页
第5页 / 共10页
点击查看更多>>
资源描述

《Linux操作系统实验报告存储管理试验》由会员分享,可在线阅读,更多相关《Linux操作系统实验报告存储管理试验(10页珍藏版)》请在金锄头文库上搜索。

1、电子信息学院实验报告书课程名:Linux操作系统实验 题 目: 实验三 存储管理试验 实验类别 【验证】 班 级: BX0907 学 号: 09 姓 名: 吴沛儒 评语:实验态度:认真( ) 一般( ) 差( )实验结果:正确( ) 部分正确( )错( )实验理论:掌握( ) 熟悉( ) 了解( ) 不懂( )操作技能:强( ) 一般( ) 差( )实验报告:好( ) 一般( ) 差( )成绩: 指导教师: 胡静 批阅时间: 年 月 日成绩: 指导教师: 宁建红 批阅时间: 年 月 日1、 实验内容或题目(1)模拟初始内存页面分配(数组、结构体均可) (2)实现Buddy heap算法 (3)

2、通过键盘输入随机产生申请和释放操作 请求:r8代表申请8个页面。 释放:f4代表释放4个页面。 (4)每个申请或释放操作,都在屏幕上显示操作前与操作后的内存分配的对比图。 (5)实验假设申请和释放的页数都是2的整次幂。(1)建立工作集页面模型。 (2)利用随机函数动态生成进程访问页面的序列号。 (3)实现FIFO页面淘汰算法。 (4)实现页故障率反馈模型。2、 实验目的与要求(1) 用C语言是实现模拟Linux系统中连续内存分配用到的伙伴对算法。 (2) 通过链表的形式输出在内存申请和释放过程中内存状态的对比图。(1)了解工作集模型的原理及其特点。 (2)实现页故障率反馈模型。3、 实验步骤与

3、源程序1. Buddy heap算法模拟源程序; #include #include typedef struct block int size; int start; int loc; struct block *next; struct block *prior; block;int maxsize=512; block *note; block *id10;void printmem()int i;for(i=9; i=0;i-)printf(%d -,i);block * temp = (struct block *)malloc(sizeof(struct block);temp =

4、 idi-next;while(temp!=NULL)printf(%d(%s)(%d)-,temp-size,temp-loc=1?占用:空闲,temp-start); temp=temp-next;printf(n);void init()int i;for(i=0;iprior=idi;idi-next=NULL;note=(struct block *)malloc(sizeof(struct block);note-size=maxsize;note-start=0;note-loc=0;note-next=NULL;id9=(struct block *)malloc(sizeof

5、(struct block);id9-next=note;id9-prior=id9;note-prior=id9;printmem();int power(int x,int y) int k=0,tmp=1;for(;knext;int flag=0,isFirst=0;while(pend!=NULL)if(pend-loc=0) if(isFirst=0)idtempId-next=pend-next;else pend-prior-next=pend-next;int size=(pend-size)/2;int start=pend-start;newu-size=size;new

6、u-start=start;newf-start=start+size;newu-loc=0;newf-size=size;newf-loc=0;newf-prior=newu;newu-next=newf;newf-next=NULL;tempId-;cend=idtempId;while(cend-next!=NULL)cend=cend-next;cend-next=newu; newu-prior=cend;flag=1;return 1;else pend=pend-next;isFirst+;if(flag=0)tempId=tempId+1;if(tempIdnext;int n

7、extStart=first-start+first-size;int preStart=first-start-first-size;int flag=0,isFirst=0;while(second!=NULL)if(second-start=nextStart | second-start=preStart) & second-loc=0)merger-size=(first-size)+(second-size);merger-loc=0;merger-start=(first-start)start)?(first-start):(second-start);if(first-nex

8、t!=NULL)first-next-prior=first-prior;if(first-prior-prior)=first-prior)idtempId-next=first-next;else first-prior-next=first-next;if(second-next!=NULL)second-next-prior=second-prior;if(isFirst=0)idtempId-next=second-next;elsesecond-prior-next=second-next;tempId+;merger-next=idtempId-next;merger-prior

9、=idtempId;if(idtempId-next!=NULL) idtempId-next-prior=merger;idtempId-next=merger;if(tempIdnext;isFirst+;return 1;int freeb(int size)block * first=(struct block *)malloc(sizeof(struct block);int tempId=root(2,size);first=idtempId-next;int flag=0;while(first!=NULL)if(first-loc=1)first-loc=0;flag=1;break;else first=first-next;if(flag=1)merge(tempId,first); printmem();else printf(需要释放

展开阅读全文
相关资源
相关搜索

当前位置:首页 > 办公文档 > PPT模板库 > 总结/计划/报告

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号