Nachos file system, Operating System

Assignment Help:

File System Interface and Implementation

The Nachos file system, as distributed, uses a single-level index allocation method for data allocation of files. In the current design, the file header (i-node) of a file can point to only NumDirect (its value is 30) data sectors. Therefore, the maximum size of a file is NumDirect*SectorSize, or 3840 bytes. In Laboratory 5, you have made Nachos files extendable. That is, one can increase the size of a file by writing more data to it. But, the maximum size of a file is still the same. You simply cannot put more data than 3840 bytes to a Nachos file. Programming Task: you are required to further change the Nachos file system to increase the maximum file size by using a two-level index allocation method similar to the UNIX file system. In particular, you will use the last entry of array dataSectors[] to store the sector number of the secondary indirect file header (i-node) when necessary. Figure ?? shows the file header structure for a file that is large enough to require two header sectors. Note that there is a new member required in the file header. The indirect member of the file header points to the secondary file header. Why are there are two links from the primary to the secondary header? The answer is because they are both needed at different times, and play different roles. For instance, when opening a file, the headers must be read from disk. The directory contains the sector number of the first header only, so that (primary) header must contain the sector number where the secondary file header can be found. However, once a file is open, and read and writes operations are being carried out, Nachos uses the file headers to determine where the data sectors reside on disk. As the Open File object can only point to one File Header object (the primary header), the primary

1510_Nachos file system.png

Figure: Two level file headers

Header must contain a pointer (a memory address, not a sector number) to the secondary  file Header object.

So in summary, within a file header, dataSectors [NumDirect-1] is a "sector pointer" to the on-disk header, while indirect is an \object pointer" to an in-memory object.

Note also that numBytes and numSectors in the secondary header is not used and has no meaning.

The new definition of the data members of FileHeader should be as follows:

private:

int numBytes; // Number of bytes in the file

int numSectors; // Number of data sectors in // the file

FileHeader *indirect; // pointer to the indirect header

int dataSectors[NumDirect]; // Disk sector numbers for each

// data block in the file

Because we are adding a new data member, but the header must still fit into one sector, the definition of numDirect should change to:

#define NumDirect ((SectorSize - 3 * sizeof(int))/sizeof(int))

Here are a few other definitions that may be of use in coding the solution.

#define NumPrimary (NumDirect-1)

#define MaxFileSectors (NumPrimary+NumDirect)

#define MaxFileSize (MaxFileSectors * SectorSize)

If the sector size is 128 bytes, and integers occupy 4 bytes (the de- fault Nachos/Intel installation), then NumDirect = 29, NumPrimary = 28, MaxFileSectors = 57, and MaxFileSize = 7296. NumPrimary is the number of data sector elements that can be ad- dressed by the primary header. The elements are dataSectors[0] to dataSectors[NumPrimary-1]. In the primary header, the el- ement dataSectors[NumPrimary] will contain the sector number of the secondary header.

  • The numBytes and numSectors members are only used in the primary header; they are ignored (wasted space) in the secondary header.
  • The indirect member is always null in a secondary header.
  • When the le header is written back to disk, the indirect eld will also be written. When it is subsequently read from disk, say when appending to a le, the indirect pointer value will be invalid as the object to which it pointed should have been deleted. The FetchFrom method will have to instantiate a new secondary header and assign its address to indirect.
  • When a primary header is fetched from the le system, the presence of a secondary header can be determined by testing either numSectors>NumPrimary or indirect!=NULL (assum- ing indirect has been properly initialized).
  • The secondary le header is not always present: if the size is small, the le system does not need to allocate the indirect i-node. The indirect i-node exists only if the size exceeds ((NumDirect-1) * SectorSize). The secondary le header is dynamically created only if and when it is needed.

Related Discussions:- Nachos file system

Define local procedure call, Q. What kinds of services does the process man...

Q. What kinds of services does the process manager provide? Define local procedure call? Answer: The process manager offers services for creating and deleting and using proce

What are the differences between process and thread, What are the differenc...

What are the differences between process and thread? The fundamental difference between a process and a thread is that a process has an entire copy of the program to itself and

Problem, whats the problem in two state model ?

whats the problem in two state model ?

Subject: system analysis (2000 word), Overview: In this assignment, you are...

Overview: In this assignment, you are going to perform a system analysis and design of a membership and facility management system of a gymnasium of given case study Task: You are

Memory management, with aid of diagram describe 2 types of fixed partition ...

with aid of diagram describe 2 types of fixed partition allocation used in operating system

Explain partitions and mounting, Partitions and mounting A disk can be ...

Partitions and mounting A disk can be sliced into many partitions, or a partition can span multiple disks. Every partition can be either "raw", having no file system, or "cooke

Define a election algorithm, Consider a setting where processors are not as...

Consider a setting where processors are not associated with unique identifiers but the total number of processors is known and the processors are organized along a bidirectional ri

Interrupt-driven i/o to manage a single serial port, Q. Why might a system ...

Q. Why might a system utilize interrupt-driven I/O to manage a single serial port however polling I/O to manage a front-end processor such as a terminal concentrator? A

What is a latency time, What is a Latency Time Latency Time is the time...

What is a Latency Time Latency Time is the time required through a sector to reach below read/write head.

Write a short note on pcb, Write a short note on PCB? Every process is ...

Write a short note on PCB? Every process is represented in the operating system by a process control block also called a task control block. It contains more information regard

Write Your Message!

Captcha
Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd