博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Extendable Files
阅读量:6238 次
发布时间:2019-06-22

本文共 5196 字,大约阅读时间需要 17 分钟。

hot3.png

 

  Laboratory 5: Extendable Files

:Objectives(实验目标)

The purpose of this lab session is to help you start to work on extending the Nachos file system, the

programming task of Assignment 3.

The work required in this laboratory session itself is part of Assignment 3.

The Nachos file system is a simple file system with many restrictions. One of them is that the size

of the file is not extendable: once you specify the size of a file upon its creation, the size of the file

is fixed throughout its lifetime. In this laboratory session, you are going to extend the Nachos file

system to allow the size of files to be extended. In particular, we want the new Nachos file system

to have the following features:

_ When a file is created, its initial size can be set to 0.

_ The size of a file can be increased if more data are written to the file.

For example, if the initial size of a file is 100 bytes and a write operation for 100 bytes data from the

position 50 (the first byte is at position 0) will extend the size of the file to 150 bytes. The situation

is illustrated in Figure 10.1, in which (a) represents the initial size (100 bytes) of the file. The light

shadow represents the current contents of the file. (b) represents the new 100 bytes of data to be

written from position 50. (c) shows the extended size of the file with dark shadow representing the

new data.

The current Nachos file system does not allow the file size to be extended like this. Your task is to

design and implement the extension of the Nachos file system to have these new features.

:实验环境

After you finish the analysis, you can start to design and implement the changes to the existing

Nachos file system. Your working directory is ../lab5/. There is one directory test in ../lab5

which contains the test files. You need to set up the arch subdirectory hierarchy and your new

makefiles in ../lab5. You also have to make a decision as to which files in ../filesys/ need to

be copied to ../lab5 in order to modify them.

The two files main.cc and fstest.cc in ../lab5/ are new and include many new file system

commands to test the new features required. We will discuss these new commands in Section 10.4.

main.cc is complete and you should not change it. fstest.cc is almost complete except that you

need to uncomment four lines in it. In both functions Append(...) and NAppend(...), you can

see the following three lines:

// Write the inode back to the disk, because we have changed it

// openFile->WriteBack();

// printf("inodes have been written back\n");

You need to uncomment the last two lines after you add Writeback() function to class OpenFile.

Why do you need this function for OpenFile? Think about it.

Use the following guidelines for the implementation and coding.

:关键代码注释:

Read files main.cc and fstest.cc in ../lab5/ and make sure that you understand how these

new commands are implemented.

When testing the new Nachos file system, start with a fresh DISK by removing the old DISK and

executing nachos -f. Then execute the following commands in the order:

nachos -cp test/small small

nachos -ap test/small small

nachos -cp test/empty empty

nachos -ap test/medium emtpy

Your file system dump with nachos -D at this point should be like this:

Bit map file header:

FileHeader contents. File size: 128. File blocks:

2

File contents:

\ff\7\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\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

Directory file header:

FileHeader contents. File size: 200. File blocks:

3 4

File contents:

\1\12\11@\5\0\0\0small\0\0\0\0G\5\8\1H\5\8\8\0\0\0empty\0\0\0\0\0\0\0\0G

\5\8\0\0\0\0\0\0\0\00\0\0\0\e0\12\11@\0\12\11@\10G\5\8X\13\0\0\d0\15\11@

\18\0\0\0\0\12\11@\c8\12\11@\80G\5\8\18\0\0\0‘\0\0\0\0\0\0\0\0\0\0\0\2\0

\0\0\a0F\5\8\0\0\0\0\0\0\0\0\18\0\0\0

\0\0\0\0\1\0\0\0\a8D\5\8\0\11\0\0\c8\15\11@H\0\0\0\f8\12\11@\f8\12\11@\0F

\5\8\0\0\0\0\0\0\0\00\0\0\0\e0\12\11@\0\12\11@\90D\5\8\c8\15\11@HH\5\8\18

\0\0\0

Bitmap set:

0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10,

Directory contents:

Name: small, Sector: 5

FileHeader contents. File size: 168. File blocks:

6 7

File contents:

small file small file small file\asmall file small file small

file\a***end of file***\asmall file small file small file\asm

all file small file small file\a***end of file***\a

Name: empty, Sector: 8

FileHeader contents. File size: 162. File blocks:

9 10

File contents:

medium file medium file medium file\amedium file medium file med

ium file\amedium file medium file medium file\amedium file medi

um file medium file\a***end of file***\a

No threads ready or runnable, and no pending interrupts.

Assuming the program completed.

Machine halting!

Ticks: total 8490, idle 8000, system 490, user 0

Disk I/O: reads 16, writes 0

Console I/O: reads 0, writes 0

Paging: faults 0

Network I/O: packets received 0, sent 0

Cleaning up...

四:调试记录:

记录如上.

:运行结果分析:

本实验通过在fstest.cc中增加一个append方法,在append方法中定义了文件追加命令,定义了-ap方法的实现,这样就可以实现文件的追加,在测试过程中,可以明显的看到在nachos文件的末尾增加了你要增加的内容,主要在实现此方法的过程中遇到了程序的bug,使我知道了调试的过程,解决问题的过程。

转载于:https://my.oschina.net/yanjianhai/blog/178636

你可能感兴趣的文章
做个精致的程序员
查看>>
挂载U盘参数大全
查看>>
解决macbook键盘失灵问题
查看>>
我总是在市井小人成堆的地方修身养性 对山中云蒸雾缭的神仙往事嗤之以鼻...
查看>>
转载 oracle数据库名、实例名、ORACLE_SID、数据库域名、全局数据库名、服务名...
查看>>
Eclipse 配置 Intellij Idea 主题
查看>>
建立软件开发团队时要避免的7个问题
查看>>
将字符序列用其反转形式取代
查看>>
在Eclipse中制作和使用struts2配置文件提示插件
查看>>
操作系统
查看>>
从需求向设计转化的密码
查看>>
360浏览器极速模式pdf文件不能预览问题
查看>>
CAS:PKIX path building failed
查看>>
测试php与mysql的连接是否成功的多种方法
查看>>
15条SQLite3数据库常用语句
查看>>
二叉树中找两个结点的最近的公共祖先结点
查看>>
Mac下sqlite3的学习总结
查看>>
基本配置实验
查看>>
使用适合的质量工具
查看>>
Linux 必学和要掌握的路径
查看>>