




下载本文档
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、.GDOU-B-11-112广东海洋大学学生实验报告书(学生用表)实验名称 存储管理课程名称操作系统课程号学院(系)软件学院专业软件工程班级学生姓名学号实验地点实验日期一、实验目的修改MINIX操作系统内存管理的源程序,将MINIX的首次适应算法改为最佳适应和最差适应算法,对修改之后的MINIX源代码进行重新编译和重新启动,以测试你修改的正确性。2、 实验内容1、 打开Minix3,进入alloc.c所在目录2、修改原算法为最佳适应算法(BEST_FIT)和最差适应算法(WORST_FIT)的程序如下:#include pm.h#include #include #include #inclu
2、de #include mproc.h#include ././kernel/const.h#include ././kernel/config.h#include ././kernel/type.h#define NR_HOLES (2*NR_PROCS)/* max # entries in hole table */#define NIL_HOLE (struct hole *) 0PRIVATE struct hole struct hole *h_next;/* pointer to next entry on the list */ phys_clicks h_base;/* wh
3、ere does the hole begin? */ phys_clicks h_len;/* how big is the hole? */ holeNR_HOLES;PRIVATE u32_t high_watermark=0;PRIVATE struct hole *hole_head;/* pointer to first hole */PRIVATE struct hole *free_slots;/* ptr to list of unused table slots */#define s (phys_clicks) -1)FORWARD _PROTOTYPE( void de
4、l_slot, (struct hole *prev_ptr, struct hole *hp) );FORWARD _PROTOTYPE( void merge, (struct hole *hp) );#define s()(0)/*=* *alloc_mem *=*/PUBLIC phys_clicks alloc_mem(clicks)phys_clicks clicks;/* amount of memory requested */#define USING_BEST_FIT#ifdef USING_BEST_FIT /先找到第一个满足要求的空洞, /再以第一个为标准寻找最适合的空
5、洞。 /当最适合的空洞完全吻合 /就直接划给它,当空洞较大时就切割。 /首先注册目标指针、目标前一个指针、头指针 /记录目标大小和目前最适合大小 register struct hole *hp; register struct hole *prevAim_ptr; register struct hole *Aim_ptr; phys_clicks old_base; /如果循环一次都没找到 /就把可以退出内存的进程赶出去 /再循环 do hp = hole_head; prevAim_ptr = NIL_HOLE; Aim_ptr = NIL_HOLE; for(;hp != NIL_HO
6、LE & hp-h_base h_next) /find the best hole if(hp-h_len = clicks) old_base = hp-h_base; /* remember where it started */ hp-h_base += clicks; /* bite off */ hp-h_len -= clicks; /* ditto */ del_slot(prevAim_ptr, hp);/* Delete the hole which used up completely. */ /* Remember new high watermark of used
7、memory. */ if(hp-h_base high_watermark) high_watermark = hp-h_base; return(old_base); /当从没记录过合适内存时 /把遇到的第一个合适节点保存在aim中 if(hp-h_len clicks & Aim_ptr = NIL_HOLE) Aim_ptr=hp; /当找到一个比原来aim更合适的空间 /记录新的空间 if(hp-h_len clicks & hp-h_len h_len) /mark it down Aim_ptr=hp; /we found it if(Aim_ptr != NIL_HOLE) o
8、ld_base = Aim_ptr-h_base; /* remember where it started */ Aim_ptr-h_base += clicks; /* bite off */ Aim_ptr-h_len -= clicks; /* ditto */ /* Remember new high watermark of used memory. */ if(Aim_ptr-h_base high_watermark) high_watermark = Aim_ptr-h_base; return(old_base); while(s(); return(NO_MEM); #e
9、ndif #ifdef USING_WORST_FIT /先找到第一个满足要求的空洞, /再以第一个为标准寻找最适合的空洞。 /当最适合的空洞完全吻合 /就直接划给它,当空洞较大时就切割。 /首先注册目标指针、目标前一个指针、头指针 /记录目标大小和目前最适合大小 register struct hole *hp; register struct hole *prevAim_ptr; register struct hole *Aim_ptr; phys_clicks old_base; /如果循环一次都没找到 /就把可以退出内存的进程赶出去 /再循环 ; do hp = hole_head;
10、 prevAim_ptr = NIL_HOLE; Aim_ptr = NIL_HOLE; for(;hp != NIL_HOLE & hp-h_base h_next) /当从没记录过合适内存时 /把遇到的第一个合适节点保存在aim中 if(hp-h_len = clicks & Aim_ptr = NIL_HOLE) Aim_ptr=hp; /当找到一个比原来aim更合适的空间 /记录新的空间 if(hp-h_len = clicks & hp-h_len Aim_ptr-h_len) /mark it down Aim_ptr=hp; /we found bigestif(hp-h_nex
11、t=NIL_HOLE)old_base =Aim_ptr-h_base;Aim_ptr-h_base+=clicks;Aim_ptr-h_len-=clicks;/* Remember new high watermark of used memory. */ if(Aim_ptr-h_base high_watermark) high_watermark = Aim_ptr-h_base; return(old_base); while(s(); return(NO_MEM); #endif 3、 保持当前目录不变(即usrsrcserverspm),输入make命令,编译程序4、重新编译整个minix,生成新的minix映像文件,并将minix映像文件复制到 boot目录之中。输入如下命令:cd usrsrctoolsmake imagecp image boottest
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 【正版授权】 IEC 60305:1995 EN-D Insulators for overhead lines with a nominal voltage above 1000 V - Ceramic or glass insulator units for a.c. systems - Characteristics of insulator unit
- 校园电力安全知识培训
- 校园消防知识培训方案课件
- 防洪考试题及答案
- 立业理论考试题及答案
- 销售核算面试题及答案
- 车体安全测试题及答案
- 乡村全科考试试题及答案
- 申论助教面试题及答案
- 2025年福建省泉州技师学院招聘合同教师考试笔试试题(含答案)
- 劳务派遣工作知识培训课件
- 无人机反制设备原理课件
- 2025年道路运输两类人员安全员考核分享题库及答案
- 中国肺血栓栓塞症诊治、预防和管理指南(2025版)
- 工会招聘考试题及答案
- 1.1认识社会生活 教案 2025-2026学年统编版道德与法治八年级上册
- 山东省技工学校模拟面试全新系列题目
- 第一章数字印刷概述课件
- 【医院管理】-科研创新助推学科建设课件
- 新课标高考英语词汇表3500
- 工资现金发放证明书
评论
0/150
提交评论