教学文库网 - 权威文档分享云平台
您的当前位置:首页 > 精品文档 > 学前教育 >

山大操作系统课程设计报告(全套)(9)

来源:网络收集 时间:2026-05-20
导读: } } delete [] data; /*revised*/ } bool FileHeader::AppSectors(BitMap *freeMap, int appFileSize) { /*revised*/ if(appFileSize int restFileSize = SectorSize * numSectors - numBytes; if(restFileSize >=

} }

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字,全部文档内容请下载后查看。喜欢就下载吧 ……

山大操作系统课程设计报告(全套)(9).doc 将本文的Word文档下载到电脑,方便复制、编辑、收藏和打印
本文链接:https://www.jiaowen.net/wendang/598633.html(转载请注明文章来源)
Copyright © 2020-2025 教文网 版权所有
声明 :本网站尊重并保护知识产权,根据《信息网络传播权保护条例》,如果我们转载的作品侵犯了您的权利,请在一个月内通知我们,我们会及时删除。
客服QQ:78024566 邮箱:78024566@qq.com
苏ICP备19068818号-2
Top
× 游客快捷下载通道(下载后可以自由复制和排版)
VIP包月下载
特价:29 元/月 原价:99元
低至 0.3 元/份 每月下载150
全站内容免费自由复制
VIP包月下载
特价:29 元/月 原价:99元
低至 0.3 元/份 每月下载150
全站内容免费自由复制
注:下载文档有可能出现无法下载或内容有问题,请联系客服协助您处理。
× 常见问题(客服时间:周一到周五 9:30-18:00)