D-Term 2006 CS 4513 Prof. D. Finkel

 

Assignment 1

 

Due Date: Thursday, April 6 at 9:50 AM

 

Goal: The overall goal of this assignment is to implement several data structures to simulate keeping track of free blocks on disk and which blocks belong to which file, in the style of a Unix file system. Your program must be written in C++ or Java, and must run on the CCC Unix machines.

Your program will use a bitmap to keep track of which blocks on the disk are free. Assume that there are 128 blocks, numbered 0 127; the bitmap should have one bit per block. Make the number of blocks a constant you define, so it will be easy to change the number of blocks later.

 

In addition, you will need an array of i-nodes. Your system will have a maximum of 20 i-nodes. Again, make this quantity a constant, so it can be changed later. For this assignment, the i-node will only contain up to 10 direct block numbers. It will not include any of the header stuff that real i-nodes contain and it will not include indirect block numbers.

 

All the files will reside in a single directory. A directory entry for a file will consist of the file name and the i-node number for that file.

 

Your program will support the following operations:

 

C create a file with the indicated number of blocks. Example: C myfile.txt 3 When a create command is encountered, the required number of blocks should be allocated from the free list bitmap, a free i-node should be allocated, the block numbers should be entered into the i-node, and a directory entry created. The create command should fail if a file with that filename already exists, or if the required number of free blocks are not available, or if a free i-node is not available.

 

E extend the specified file by the indicated number of blocks. Example: E myfile.txt 2 This command should fail if the specified file does not exist, or if the required number of free blocks is not available.

 

D delete a specified file. Example D myfile.txt When a delete command is encounted, all the resources allocated for the file should be deallocated. The delete command should fail if the specified file does not exist.

 

R reset the file system. This command should restore your file system to its initial state, with no files in the directory, no i-nodes in use, and all blocks free.

 

P print all file system information. For each file in the file system, print the name of the file and a list of all the blocks currently allocated to this file.

 

Your program should start with all the blocks free, and read in commands from a file or from standard input. There will be a carriage return following each command. After processing each operation, print a confirmation message of the following form to the screen:

 

created myfile.txt 3 blocks: 13 14 17

extended myfile.txt 2 blocks: 22 26

create yourfile.txt failed 4 blocks not available

delete yourfile.txt failed. file does not exist

 

To keep everyone's results the same, your program must always allocate the lowest number block available from the bitmap.

 

Your program should recognize the following command line switches:

 

-s run silently (no printed output). You should use this switch when you are timing your program. If s is selected and a P command is issued, the P command should be ignored.

-f filename read the commands in the file filename. If the f switch is absent, read the commands from standard input.

 

Timing your program: Use /usr/bin/time to time your program. To use this program, type

 

/usr/bin/time command

 

where command is some system command or the name of an executable you want to run. This will run your command, and afterwards report three times in seconds: real, user and sys. The real time is the amount of elapsed time to run your program, including any time spent running other people's programs; the user time is the time spent executing your code; and the sys time is the time spent on operating system services to run your program. You want to record the user time for your program. It's important to run all your timed test programs on the same machine.

 

If you run /bin/time on your own programs, you might very likely get times of 0 unless you make the command file very large. To try out /bin/time, try compiling something under /bin/time. Don't confuse /bin/time with time, which works differently. If you wish to use some other method to time your program, please consult with the TA, SA or me beforehand.

 

A file of commands to time will be made available shortly before the program is due. The test file will end with the command "C", so if timing your program gives a result of 0, run the test file through your program several times. (This will require a modification to your program.)

 

Submitting your program: Use the turnin program to submit your assignment. Turn in your program files, but do not turn in any executable files. Include a file named build.sh to compile your program. If you have a makefile, build.sh could simply call make.

 

Include a README file explaining what level of the assignment you have completed, and a list of all the implemented features, and explain how to run your program. Be sure to include the documentation files as specified in the CS Department Documentation Standard, located at http://www.cs.wpi.edu/Help/documentation-standard.html You do not need to include a program listing or sample runs in your documentation.

 

C-Level Assignment: To receive a C on this assignment, implement only the bimap for keeping track of free blocks and a directory structure.. For the C level of the assignment, the directory should story the file name and the numbers of the block used by this file; the directory will not include an i-node number. Time the performance of your program.

 

B-Level Assignment: To receive the grade of B on this assignment, implement the bitmap, the i-nodes, and the directory, and imlplement all of the functions described above.

 

A-Level Assignment: To receive the grade of A for this assignment, you must implement the functionality of the B-level assignment, and add the ability to do contiguous allocation (allocating consecutive free blocks only). If the requested number of contiguous free blocks is not available, then no blocks should be allocated. Add a command line switch, -c, to run your program using contiguous allocation; if c is not present, run the original non-contiguous allocation. Time the contiguous allocation implementation as well as the original, non-contiguous implementation.

 

Extra credit (for the A-Level Assignment only): For extra credit, compare the performance of the contiguous allocation method with the corresponding non-contiguous method. The (possible) savings from using contiguous allocation come from reducing the amount of disk head movement in writing and reading files. Thus your performance analysis of contiguous allocation cannot depend only on the results of timing the running of your program, since your program does not simulate reading and writing. You will need to do some analysis beyond timing your program.; you will have to decide how to do this analysis. The TA, SA and I will be happy to discuss your plans for the analysis with you.