下载此文档

操作系统实验(3)-存储管理实验.doc


文档分类:IT计算机 | 页数:约38页 举报非法文档有奖
1/38
下载提示
  • 1.该资料是网友上传的,本站提供全文预览,预览什么样,下载就什么样。
  • 2.下载该文档所得收入归上传者、原创者。
  • 3.下载的文档,不会出现我们的网址水印。
1/38 下载此文档
文档列表 文档介绍
操作系统实验(3)

实验题目:存储管理实验
课程名称:操作系统
学院:管理学院
专业班级:
学号(1):
姓名(1):
学号(2):
姓名(2):
任课教师:
2010年05月06日
学院:管理学院班级:
组员: 组员:
评定:
实验题目:存储管理实验
实验目的:通过编写和调试存储管理的模拟程序以加深对存储管理方案的
理解。
(2)实验内容:设计一个可变式分区分配的存储管理方案。并模拟实现分区的
分配和回收过程。
对分区的管理法可以是下面三种算法之一:
首次适应算法
循环首次适应算法
最佳适应算法
源代码(含注释):
首次适应算法(FF):
#include<>
#include<>
#include<>
#include<>
struct nc{
int n; /*内存号*/
int rl; /*内存容量*/
int sdz; /*首地址*/
struct nc *next;}*head;
struct PCB{
int num; /*进程号*/
char name[10]; /*进程名*/
int nv; /*进程大小*/
int itime; /*进程进入内存时间*/
int ncn; /*装入的内存号*/
int sdzv; /*存入内存的首地址*/
int ntime; /*进程运行总时间*/
int rtime; /*进程运行时间*/
char state; /*进程状态*/
struct PCB *link;}*tou;
int all; /*进程总数变量*/
int tim=0; /*当前时间变量*/
void innc() /*将进程装入内存*/
{
struct nc *md;
struct PCB *xx;
xx=tou;
while(xx!=NULL)
{if(xx->ncn==0&&(xx->itime<=tim||xx->itime<=tim-1))
{md=head;
while(md!=NULL)
{if(md->rl>=xx->nv)
{xx->ncn=md->n;
xx->sdzv=md->sdz;
md->sdz=md->sdz+xx->nv;
md->rl=md->rl-xx->nv;
goto leep;
}
md=md->next;
}
leep:if(md==NULL) printf("the process %s can't into nc\n",xx->name);
}
xx=xx->link;
}
}
void sort()
{
struct PCB *p1,*p2;
p1=p2=tou;
while(p1->link!=NULL)
{
if((p1->link)->itime<=tim&&(p1->link)->ncn!=0)
{tou=p2=p1;
while(p1->link!=NULL) {p1=p1->link;}
p1->link=tou;tou=tou->link;p2->link=NULL;
}
else p1=p1->link;
}
}
void creatnc() /*创建内存链表*/
{
struct nc *p1,*p2;
int ncx,ncy;
printf("input the numeber of nc(input 0 to end):");
scanf("%d",&ncx);
p2=(struct nc*)malloc(sizeof(struct nc));p1->next=NULL;head=p2=p1;
while(ncx>0)
{
p1->n=ncx;
printf("input the large of nc:");
scanf("%d",&p1->rl);
printf("input the sdz of nc:");
scanf("%d",&ncy);
p1->sdz=ncy;
p2->next=p1;p2=p1;
printf("input the numeber of nc(input 0 to end):");
scanf("%d",&ncx);
if(ncx<=0) break;
p1=(struct nc*)malloc(sizeof(struct nc));
p1->next=NULL;
}
}
void cr

操作系统实验(3)-存储管理实验 来自淘豆网m.daumloan.com转载请标明出处.

非法内容举报中心
文档信息
  • 页数38
  • 收藏数0 收藏
  • 顶次数0
  • 上传人3346389411
  • 文件大小0 KB
  • 时间2013-01-07