山大操作系统课程设计报告(全套)(9)
} }
delete [] data; /*revised*/ } bool
FileHeader::AppSectors(BitMap *freeMap, int appFileSize) {
/*revised*/
if(appFileSize <= 0)return false;
int restFileSize = SectorSize * numSectors - numBytes;
if(restFileSize >= appFileSize) {
numBytes += appFileSize; return true; } else {
int moreFileSize = appFileSize - restFileSize;
if(freeMap->NumClear()< divRoundUp(moreFileSize, SectorSize)) return FALSE;
else if(NumDirect + NumDirect2 <= numSectors + divRoundUp(moreFileSize, SectorSize)) return FALSE;
int i = numSectors;
numBytes += appFileSize;
numSectors += divRoundUp(moreFileSize, SectorSize);
/*toNextNode 是保留第二个索引节点的扇区号*/
int toNextNode = NumDirect-1; //test if has the second node if(dataSectors[toNextNode] == -1) {
//test if need the second node if(numSectors < toNextNode) for( ; i < numSectors; i++)
dataSectors[i] = freeMap -> Find();
//need the second node else {
for( ; i< toNextNode ; i++)
dataSectors[i]= freeMap ->Find();
dataSectors[toNextNode] = freeMap ->Find(); int dataSectors2[NumDirect2]; for ( ; i < numSectors ; i++)
dataSectors2[i - toNextNode] = freeMap->Find();
synchDisk->WriteSector(dataSectors[toNextNode], (char *)dataSectors2); } } /*
* If before appending, there is already a secondary index */
//First read the dataSectors2 from the Disk. //Then, append the file size.
//At last, write back the secondary index block into the sector, else {
int dataSectors2[NumDirect2];
synchDisk->ReadSector(dataSectors[toNextNode], (char *)dataSectors2); for( ; i < numSectors; i++)
dataSectors2[i-toNextNode] = freeMap -> Find();//the var toNextNode==the number of int that synchDisk->WriteSector(dataSectors[toNextNode], (char *)dataSectors2);//the fefault synchDisk } }
return TRUE; /*revised*/ }
运行结果:首先运行命令 ./nachos –f 格式化Nachos磁盘
然后运行 ./nachos –ap test/big big 若干次,知道出现提示,文件太大不能再追究为止。 start value: 1168, amountRead 10, result of write: 10 start value: 1178, amountRead 10, result of write: 10 start value: 1188, amountRead 10, result of write: 10 start value: 1198, amountRead 10, result of write: 10 start value: 1208, amountRead 8, result of write: 8 inodes have been written back
No threads ready or runnable, and no pending interrupts. Assuming the program completed.
Machine halting!
Ticks: total 1091100, idle 1086750, system 4350, user 0 Disk I/O: reads 76, writes 68 Console I/O: reads 0, writes 0 Paging: faults 0
Network I/O: packets received 0, sent 0
Cleaning up...
lu@ubuntu:~/csc2404/nachos-3.4/code/filesys2nodehdr$ ./nachos -ap test/big big The appending file is too big! Appending file failed
No threads ready or runnable, and no pending interrupts. Assuming the program completed. Machine halting!
Ticks: total 4200, idle 3970, system 230, user 0 Disk I/O: reads 7, writes 0 Console I/O: reads 0, writes 0 Paging: faults 0
Network I/O: packets received 0, sent 0
Cleaning up...
然后运行 ./nachos -ap test/small big ,直到可以出现The appending file is too big!
lu@ubuntu:~/csc2404/nachos-3.4/code/filesys2nodehdr$ ./nachos -ap test/small big openFile see filesize 7790 value of start 38
start value: 38, amountRead 10, result of write: 10 start value: 48, amountRead 10, result of write: 10 start value: 58, amountRead 10, result of write: 10 start value: 68, amountRead 8, result of write: 8 inodes have been written back
No threads ready or runnable, and no pending interrupts. Assuming the program completed. Machine halting!
Ticks: total 83100, idle 82470, system 630, user 0 Disk I/O: reads 14, writes 6 Console I/O: reads 0, writes 0 Paging: faults 0
Network I/O: packets received 0, sent 0
Cleaning up...
lu@ubuntu:~/csc2404/nachos-3.4/code/filesys2nodehdr$ ./nachos -ap test/small big The appending file is too big! Appending file failed
No threads ready or runnable, and no pending interrupts. Assuming the program completed. Machine halting!
Ticks: total 4200, idle 3970, system 230, user 0 Disk I/O: reads 7, writes 0 Console I/O: reads 0, writes 0 Paging: faults 0
Network I/O: packets received 0, sent 0
Cleaning up...
然后显示结果,运行命令 ./nachos –D
lu@ubuntu:~/csc2404/nachos-3.4/code/filesys2nodehdr$ ./nachos -D Bit map file header:
FileHeader contents. File size: 128. File blocks: 2
File contents:
\\ff\\ff\\ff\\ff\\ff\\ff\\ff\\ff\\f\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\\\0\\0
Directory file header:
FileHeader contents. File size: 200. File blocks: 3 4
File contents:
\\1\\0\\0\\0\\5\\0\\0\\0big\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\Bitmap set:
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, Directory contents: Name: big, Sector: 5 …… 此处隐藏:2614字,全部文档内容请下载后查看。喜欢就下载吧 ……
相关推荐:
- [学前教育]MC9S12XS256RMV1 xs128芯片手册4
- [学前教育]安东尼语录经典语录
- [学前教育]e级gps控制测量技术设计书
- [学前教育]苏教版2022-2022学年八年级下学期期末
- [学前教育]装修公司推广 营销
- [学前教育]家政服务合同(完整版)
- [学前教育]湖北省2016届高三联考语文试题
- [学前教育]爱立信无涯学习系统LTE题库1-LTE基础知
- [学前教育]揭秘大众柴油车作弊软件原理
- [学前教育]人才流失原因及对策分析
- [学前教育]房屋建筑施工工程劳务分包合同
- [学前教育]国际贸易实务试卷A卷09.6
- [学前教育]校园废品回收活动计划方案书范文格
- [学前教育]电大成本会计试题及答案
- [学前教育]大学物理实验 华南理工出版社 绪论答案
- [学前教育]爱丁堡产后抑郁量表
- [学前教育]液压冲击的危害、产生原因与防止方法(
- [学前教育]学生工作总结高一学生期中考试总结_020
- [学前教育]人民医院医疗废物管理规章制度大全
- [学前教育]阳光维生素的巨大抗癌潜能阅读题答案.d
- 马云在云锋基金江苏论坛闭幕式的发言
- 试论小学体育教育中的心理健康教育-教
- 语文A版一年级下册《语文乐园一》教学
- 2021四川大学物理化学考研真题经验参考
- [人教A版]2015-2016学年高中数学 第二
- 终端网点销售返利协议书
- 江苏省2015年眼科学主治医师青光眼考试
- 2017年部编人教版八年级语文上册教案
- 十一中学七年级英语上册Unit7Howmuchar
- 以赛促教的创新性实验教学机制建设实践
- 平凉市崆峒区2015七年级下生物期末试题
- 琶洲(地块五)A、B塔楼1、2#塔吊基础
- 一级医院工作制度与人员岗位职责
- 2018北京西城区高三二模理科数学试题及
- 炒股密码线技术 - 图文
- 职高学生生涯发展辅导教案
- 语文人教版四年级上册8 世界地图引出的
- 最新最新人教版二年级上册全册数学教案
- 2017高考英语全国2卷精彩试题(有问题
- 普通心理学笔记




