欢迎来到天天文库
浏览记录
ID:57091373
大小:23.00 KB
页数:7页
时间:2020-08-02
《可变分区存储管理方式的内存分配和回收教程文件.doc》由会员上传分享,免费在线阅读,更多相关内容在工程资料-天天文库。
1、可变分区存储管理方式的内存分配和回收精品文档#include//定义输入/输出函数#include//数据流输入/输出#include//字符串处理#include//参数化输入/输出constintMJ=10;//假定系统允许的最大作业数量为10typedefstructnode{intaddress;intlength;chartag[10];}job;jobfrees[MJ];intfree_quantity;joboccupys[MJ];intoccupy_quanti
2、ty;intread(){FILE*fp;charfn[10];cout<<"请输入初始空闲表文件名:";cin>>fn;if((fp=fopen(fn,"r"))==NULL){其意义是在当前目录下打开文件filea,只允许进行“读”操作,并使fp指向该文件cout<<"错误,文件打不开,请检查文件名"<3、(文件指针,格式字符串,输入表列);}return1;}收集于网络,如有侵权请联系管理员删除精品文档return0;}voidsort(){inti,j,p;for(i=0;i4、view(){inti;cout<5、;}cout<6、out<>job_name;cin>>job_length;flag=0;for(i=0;i=job_length){flag=1;}}if(flag==0){//未找到空闲区,返回cout<7、dl;}else{t=0;i=0;while(t==0){if(frees[i].length>=job_length){//找到可用空闲区,开始分配t=1;}i++;}i--;occupys[occupy_quantity].address=frees[i].address;//修改已分配区表strcpy(occupys[occupy_quantity].tag,job_name);occupys[occupy_quantity].length=job_length;occupy_quantity++;if(frees[i].length>job_lengt8、h){frees[i].address
3、(文件指针,格式字符串,输入表列);}return1;}收集于网络,如有侵权请联系管理员删除精品文档return0;}voidsort(){inti,j,p;for(i=0;i4、view(){inti;cout<5、;}cout<6、out<>job_name;cin>>job_length;flag=0;for(i=0;i=job_length){flag=1;}}if(flag==0){//未找到空闲区,返回cout<7、dl;}else{t=0;i=0;while(t==0){if(frees[i].length>=job_length){//找到可用空闲区,开始分配t=1;}i++;}i--;occupys[occupy_quantity].address=frees[i].address;//修改已分配区表strcpy(occupys[occupy_quantity].tag,job_name);occupys[occupy_quantity].length=job_length;occupy_quantity++;if(frees[i].length>job_lengt8、h){frees[i].address
4、view(){inti;cout<5、;}cout<6、out<>job_name;cin>>job_length;flag=0;for(i=0;i=job_length){flag=1;}}if(flag==0){//未找到空闲区,返回cout<7、dl;}else{t=0;i=0;while(t==0){if(frees[i].length>=job_length){//找到可用空闲区,开始分配t=1;}i++;}i--;occupys[occupy_quantity].address=frees[i].address;//修改已分配区表strcpy(occupys[occupy_quantity].tag,job_name);occupys[occupy_quantity].length=job_length;occupy_quantity++;if(frees[i].length>job_lengt8、h){frees[i].address
5、;}cout<6、out<>job_name;cin>>job_length;flag=0;for(i=0;i=job_length){flag=1;}}if(flag==0){//未找到空闲区,返回cout<7、dl;}else{t=0;i=0;while(t==0){if(frees[i].length>=job_length){//找到可用空闲区,开始分配t=1;}i++;}i--;occupys[occupy_quantity].address=frees[i].address;//修改已分配区表strcpy(occupys[occupy_quantity].tag,job_name);occupys[occupy_quantity].length=job_length;occupy_quantity++;if(frees[i].length>job_lengt8、h){frees[i].address
6、out<>job_name;cin>>job_length;flag=0;for(i=0;i=job_length){flag=1;}}if(flag==0){//未找到空闲区,返回cout<7、dl;}else{t=0;i=0;while(t==0){if(frees[i].length>=job_length){//找到可用空闲区,开始分配t=1;}i++;}i--;occupys[occupy_quantity].address=frees[i].address;//修改已分配区表strcpy(occupys[occupy_quantity].tag,job_name);occupys[occupy_quantity].length=job_length;occupy_quantity++;if(frees[i].length>job_lengt8、h){frees[i].address
7、dl;}else{t=0;i=0;while(t==0){if(frees[i].length>=job_length){//找到可用空闲区,开始分配t=1;}i++;}i--;occupys[occupy_quantity].address=frees[i].address;//修改已分配区表strcpy(occupys[occupy_quantity].tag,job_name);occupys[occupy_quantity].length=job_length;occupy_quantity++;if(frees[i].length>job_lengt
8、h){frees[i].address
此文档下载收益归作者所有