- 60
- 0
- 约3.72千字
- 约 5页
- 2016-04-24 发布于重庆
- 举报
空闲磁盘存储空间的管理位示图法
空闲磁盘存储的管理:位示图法
1:建立相应的数据结构
2:磁盘上建立一个文件,文件长度设为10MB,为该文件来模拟一个磁盘,磁盘的物理块大小为512字节
3:显示每次磁盘的请求和空间释放后的位示图状态
4显示每次磁盘的请求和空间释放后的全磁盘的状态
5:模拟文件的创建和删除,从而产生磁盘潘快请求和释放,验证以上设计
代码:
// OS暑?期ú课?程ì设Θ?计?.cpp : 定¨义?控?制?台?应畖用?程ì序ò的?入?口ú点?。£
//
#include stdafx.h
#include iostream
#include string
#include math.h
using namespace std ;
//文?件t类え?
class file
{
public:
string name ;
int occupy ;
int grade_block ;
int start ;
};
#define MAX_LINE 3
#define MAX_COLUMN 32
int BIT[32][1000];
int byte[MAX_LINE] ;
int file_count;
int judge[32] ;
int judge2[32];
int cycle ;
file f[1000];
void init(int line ,int column);
void show() ;
void set(int now_location, int occupy );
void clear(int now_location, int occupy);
void bitset(int index ,int temp_block_quantity);
void create_file(string temp_name, int temp_occupy );
void delete_file(string name);
bool byte_judge(int num,int i);
int _tmain(int argc, _TCHAR* argv[])
{
string cmd;
string file_name ;
int file_occupy ;
init( MAX_LINE, MAX_COLUMN ) ; //初?始?化ˉ
while ( cin cmd ) //
{
if( q == cmd || Q == cmd )
{
exit(0) ;
return 0 ;
}
cin file_name ;
if(create == cmd)
{
cin file_occupy ;
create_file(file_name,file_occupy);
}
else
{
delete_file(file_name) ;
}
}
return 0;
}
void show()
{
for(int i = 0 ; i MAX_LINE ; i ++)
{
for(int j = 0 ; j MAX_COLUMN ; j ++)
{
//coutBIT[i][j] ;
coutbyte_judge(byte[i],j) ;
}
cout endl ;
}
}
void set(int now_location, int occupy )
{
int line ;
int column ;
for(int i = 0 ; i occupy ; i ++ )
{
line = (now_location - i) / MAX_COLUMN ;
column = (now_location - i ) % MAX_COLUMN ;
//BIT[line][column] = 1 ;
byte[line] |= judge[column];
}
}
//清?零?
void clear(int now_location, int occupy)
{
int line ;
int column ;
for(int i = 0 ; i occupy ; i ++)
{
line = (now_location + i) / MAX_COLUMN ;
column = (now_location + i ) % MAX_COLUMN ;
//BIT[line][column] = 0 ;
byte[line] = judge2[column];
}
}
void
您可能关注的文档
最近下载
- (中级)航空油料特设维修员(四级)理论考试题(附答案).doc VIP
- GB50134-2004人民防空工程施工及验收规范.pdf VIP
- 2026年内初班试卷新疆推荐.pdf VIP
- Q/GDW 13237.1—2018 10kV架空绝缘电缆采购标准(第1部分:通用技术规范).pdf VIP
- 2024年新疆内初班数学考试卷子.docx VIP
- 综合实践认识塑料教学设计.docx VIP
- 1_2_3_4晶体的宏观对称性1.ppt VIP
- 2024年中考阅读中引用解读与对应训练(含答案).docx VIP
- 一种小型无人机低后坐挂载平台.pdf VIP
- 土肥调控对蓝莓生长与果实品质的影响及优化策略探究.docx VIP
原创力文档

文档评论(0)