欢迎来到天天文库
浏览记录
ID:55156451
大小:22.50 KB
页数:5页
时间:2020-04-29
《空闲磁盘存储空间的管理:位示图法.doc》由会员上传分享,免费在线阅读,更多相关内容在工程资料-天天文库。
1、空闲磁盘存储的管理:位示图法1:建立相应的数据结构2:磁盘上建立一个文件,文件长度设为10MB,为该文件来模拟一个磁盘,磁盘的物理块大小为512字节3:显示每次磁盘的请求和空间释放后的位示图状态4显示每次磁盘的请求和空间释放后的全磁盘的状态5:模拟文件的创建和删除,从而产生磁盘潘快请求和释放,验证以上设计代码://OS暑?期ú课?程ì设Θ?计?.cpp:定¨义?控?制?台?应畖用?程ì序ò的?入?口ú点?。£//#include"stdafx.h"#include#include#incl
2、udeusingnamespacestd;//文?件t类え?classfile{public:stringname;intoccupy;intgrade_block;intstart;};#defineMAX_LINE3#defineMAX_COLUMN32intBIT[32][1000];intbyte[MAX_LINE];intfile_count;intjudge[32];intjudge2[32];intcycle;filef[1000];voidinit(intline,intcolumn);void
3、show();voidset(intnow_location,intoccupy);voidclear(intnow_location,intoccupy);voidbitset(intindex,inttemp_block_quantity);voidcreate_file(stringtemp_name,inttemp_occupy);voiddelete_file(stringname);boolbyte_judge(intnum,inti);int_tmain(intargc,_TCHAR*argv[]){string
4、cmd;stringfile_name;intfile_occupy;init(MAX_LINE,MAX_COLUMN);//初?始?化ˉwhile(cin>>cmd)//{if("q"==cmd
5、
6、"Q"==cmd){exit(0);return0;}cin>>file_name;if("create"==cmd){cin>>file_occupy;create_file(file_name,file_occupy);}else{delete_file(file_name);}}return0;}voidshow(){for
7、(inti=0;i8、;//BIT[line][column]=1;byte[line]9、=judge[column];}}//清?零?voidclear(intnow_location,intoccupy){intline;intcolumn;for(inti=0;i10、(intindex,inttemp_block_quantity){intblock_quantity=temp_block_quantity;intfree_quantity=0;intline,column;intsign=cycle-1;for(;;cycle++){line=cycle/MAX_COLUMN;column=cycle%MAX_COLUMN;if(0==byte_judge(byte[line],column)){free_quantity++;}else{free_quantity=0;}if(free11、_quantity>=block_quantity){f[index].start=cycle-block_quantity+1;set(cycle,block_quantity);cycle++;cout<<"createfilesuccess"<
8、;//BIT[line][column]=1;byte[line]
9、=judge[column];}}//清?零?voidclear(intnow_location,intoccupy){intline;intcolumn;for(inti=0;i10、(intindex,inttemp_block_quantity){intblock_quantity=temp_block_quantity;intfree_quantity=0;intline,column;intsign=cycle-1;for(;;cycle++){line=cycle/MAX_COLUMN;column=cycle%MAX_COLUMN;if(0==byte_judge(byte[line],column)){free_quantity++;}else{free_quantity=0;}if(free11、_quantity>=block_quantity){f[index].start=cycle-block_quantity+1;set(cycle,block_quantity);cycle++;cout<<"createfilesuccess"<
10、(intindex,inttemp_block_quantity){intblock_quantity=temp_block_quantity;intfree_quantity=0;intline,column;intsign=cycle-1;for(;;cycle++){line=cycle/MAX_COLUMN;column=cycle%MAX_COLUMN;if(0==byte_judge(byte[line],column)){free_quantity++;}else{free_quantity=0;}if(free
11、_quantity>=block_quantity){f[index].start=cycle-block_quantity+1;set(cycle,block_quantity);cycle++;cout<<"createfilesuccess"<
此文档下载收益归作者所有