欢迎来到天天文库
浏览记录
ID:40512097
大小:34.52 KB
页数:6页
时间:2019-08-03
《分区式存储管理实验报告》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、操作系统实验报告(四)分区式存储器管理专业:XXX姓名:XXX班级:XXX学号:XXX指导老师:XXX2013/12/3实验三:分区式存储器管理实验一.实验目的模拟实现一个简单的固定(或可变)分区存储管理系统,进一步加深对分区分配方案设计思想的理解。二.实验内容(1)建立相关的数据结构,作业控制块、已分配分区及未分配分区;(2)实现一个分区分配算法,如最先适应分配算法、最优或最坏适应分配算法;(3)实现一个分区回收算法;(4)给定一批作业/进程,选择一个分配或回收算法,实现分区存储的模拟管理;(5)将整个过程可视化显示出来。三.实验步骤(1)任务分析:1、本实验虽然
2、不以前面实验为基础,但建议在其界面中继续增加分区存储管理功能。2、数据结构:分区说明表,用数组实现。3、存储管理:建议采取固定分区法管理内存。编写内存分配、内存回收算法。(2)程序设计:数据结构设计程序中自由链队列的结点类型可描述如下:structemptylist{intlen,address;//len为分区长度;address为分区起始地址structemptylist*next;//下一个节点};内存占用区用链表描述,其结点类型描述如下:structbusylink{charname;//进程名称intlen,address;//len为分区长度;addre
3、ss为分区起始地址structbusylink*next;//下一个节点};设全程量,设置一个自由链队列和一个占用区队列。structemptylist*empty_head=NULL;//自由链队列(带头结点)队首指针structbusylink*busy_head=NULL//占用区队列队(带头结点)首指针structbusylink*busy_tail=NULL;//占用区队列队尾指针(3)程序结果:分配几个内存后,显示其内部的分配进程如下:其中进程S是系统默认分配的进程,内存长度为5.回收过2,4以后显示如下:(4)调试与测试四.实验总结本次实验采用最佳适应
4、算法来分配内存,然后分别输出未进行内存回收时和进行回收时,内存分配情况,进行对比。当然还有其他的分配算法,在以后的学习中,如果有时间的话,我会在好好的用其他的算法进行实验。五.附录#include#include#include#includeStructemptylist{inlen,address;structemptylist*next;};structbusylink{charname;intlen,address;structbusylink*next;};Structmp
5、tylist*empty_head=NULL;structbusylink*busy_head=NULL,*busy_tail=NULL;voidinit(){Structemptylist*p;structbusylink*q;empty_head=(structemptylist*)malloc(sizeof(structemptylist));empty_head->next=NULL;busy_head=busy_tail=(structbusylink*)malloc(sizeof(structbusylink));busy_head->next=NULL
6、;p=(structemptylist*)malloc(sizeof(structemptylist));p->address=64;p->len=1024-64;p->next=NULL;empty_head->next=p;q=(structbusylink*)malloc(sizeof(structbusylink));q->name='S';//默认系统内存q->len=64;q->address=0;q->next=NULL;busy_head->next=q;busy_tail=q;}voidrequire(charname,intrequire)//分
7、配内存{structemptylist*w,*u,*v,*x,*y;structbusylink*p;x=empty_head;y=empty_head->next;while((y!=NULL)&&(y->lennext;}if(y!=NULL){p=(structbusylink*)malloc(sizeof(busylink));p->name=name;p->address=y->address;p->len=require;p->next=NULL;busy_tail->next=p;busy_tail=p;w=
此文档下载收益归作者所有