- 1、本文档共5页,可阅读全部内容。
- 2、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
- 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载。
- 4、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
空闲磁盘存储空间的管理位示图法
空闲磁盘存储的管理:位示图法
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
您可能关注的文档
- 程序设计110121.doc
- 程序设计语言B期终考试命题稿2010.doc
- 程序设计语言复习资料.doc
- 程序设计语言期末考试A.doc
- 程序设计语言实验指导书12版.doc
- 程序设计语言期末试卷C.doc
- 稍复杂的分数乘法问题.doc
- 稍复杂的分数百分数问题及答案.doc
- 稍复杂的分数除法问题.doc
- 稍复杂的分数除法问题教案.doc
- 四川省德阳市罗江中学2025届高三考前热身化学试卷含解析.doc
- 山东省枣庄现代实验学校2025届高三下学期第五次调研考试化学试题含解析.doc
- 吉林省长春市十一高中等九校教育联盟2025届高三一诊考试生物试卷含解析.doc
- 2025届江苏省盐城市伍佑中学高考仿真模拟化学试卷含解析.doc
- 2025届广西贺州中学高考冲刺押题(最后一卷)生物试卷含解析.doc
- 安徽省池州市贵池区2025届高三第一次模拟考试生物试卷含解析.doc
- 宁夏银川一中2025届高三(最后冲刺)化学试卷含解析.doc
- 广东省广州市增城区四校联考2025届高考压轴卷化学试卷含解析.doc
- 2025届邯郸市第一中学高考生物必刷试卷含解析.doc
- 2025届安徽省安庆市石化第一中学高考仿真卷化学试卷含解析.doc
文档评论(0)