This document is currently incomplete.
Assignment 4 is to be done inside of the directory code/filesys.
NOTE: The Makefile for this assignment probably needs to be modified to reflect the changes that you've made to the system in assignments two and three. For most groups you'll probably want to delete the definition of THREADS and add the definition for USE_TLB (in code/filesys/Makefile). The resulting DEFINES should look like:
DEFINES =-DUSER_PROGRAM -DVM -DUSE_TLB -DFILESYS_NEEDED -DFILESYS
I've also compiled the standard (original) version of the filesystem in /cs/course/4321/code/filesys which you should be able to execute to check if you "baseline" system is working properly. Remember that you won't be able to execute Nachos in that directory because it needs to create and write to a file named "DISK" in the current directory. Instead copy Nachos to one of your directories and try it out.
Read all of this document first.
Have a look at the the Nachos Roadmap document. In particular the following sections should prove useful:
Understand what the current implementation does: how file headers and the directory are implemented, how a file is organized, how free blocks are maintained and organized as well as how FetchFrom and WriteBack work and why they are used/needed.
You should also examine and understand the current implementation of the filesystem related classes before you start to modify any code.
In the previous assignments the file system has been simulated using the UNIX file system. This meant that when a user program called Read or Write it "held" for the duration of the entire underlying UNIX read or write call. Now that the real Nachos file system is being used a user program that causes any type of disk operations (e.g., page faults, calling Read/Write/Open/Create) will be blocked waiting for the completion of the disk operation. While that user program is blocked another user program may be run.
NOTE: these types of problems should only be caused when you have multiple user program executing concurrently. If you have this problem then it's very likely that you have bugs in the implementation of your previous assignments.
You can:
You may wish to reread the tips on Improving the File System Simulation from the previous assignment.
#define NumDirect ((SectorSize - 2 * sizeof(int)) / sizeof(int)) #define MaxFileSize (NumDirect * SectorSize)
Given the definition (shown below) of SectorSize this means that until you modify (fix) the filesystem your swap file is limited to 30 * 128 = 3840 bytes.
The disk parameters are defined in code/machine/disk.h. It's likely that these values won't have to be changed to run your programs.
#define SectorSize 128 // number of bytes per disk sector #define SectorsPerTrack 32 // number of sectors per disk track #define NumTracks 32 // number of tracks per disk #define NumSectors (SectorsPerTrack * NumTracks) // total # of sectors per disk
FILESYS -f causes the physical disk to be formatted -cp copies a file from UNIX to Nachos -p prints a Nachos file to stdout -r removes a Nachos file from the file system -l lists the contents of the Nachos directory -D prints the contents of the entire file system -t tests the performance of the Nachos file system
./nachos -f
./nachos -cp ../test/halt halt
./nachos -x halt
/* Remove a file from the file system. * Returns success (1) or failure (less than 0) */ int Remove(char *name); /* Move the read/write file offset to the specified position. * If successful it returns the new position otherwise it returns * a failure code (less than 0) */ int Seek(OpenFileId id, int newpos);
Modified: Nov 18, 1995
Created: Nov 18, 1995