The purpose of the second part of Project 2 is to familiarize you with C++ input (reading from
files and obtaining input from a user), give you more experience working with pointers, and show
you how a class you’ve previously written can be used to solve a problem efficiently.
1. File Allocation method in Operating System
The main problem that occurs in the operating system is that how we allocate the spaces to the files so
that the utilization of disk is efficient and the quick access to the file is possible. The file allocation
method defines how the files are stored in disk blocks, which represent the minimum unit of data that
can be stored to the disk. There are various types of file allocation method, but we mainly use three
major types of file allocation methods:
1. Contiguous Allocation: each file occupies a set of contiguous (i.e., one next to another) blocks.
2. Linked Allocation: each file is a linked list of storage blocks, with each block also containing
3. Indexed Allocation: A dedicated block is used to maintain an index of all storage blocks
belonging to a file (i.e., the blocks that hold the file data).
These methods are known to provide quick access to the file blocks and also the utilization of disk
space in an efficient manner. In assignment In P2.2, we will build a program that simulates
Indexed File Allocation; i.e., we wish to build a program that allows the user to break a file
into the requisite number of blocks that are then stored non-contiguously throughout the disk.
2. Indexed Allocation
In the index allocation method, we have an additional block which is known as the index block.
For each file there is an individual index block. In the index block, a data structure is used such
that the ith entry of the structure holds the disk address of the ith file block. Note that each file
has one index block but can have one or more storage blocks.
A directory contains multiple files and must therefore must maintain a list of index blocks for
the files contained therein (Figure 1 below shows how a directory entry comprises the address
of the index block). In our implementation we will consider only a single directory on the disk
(though in actuality a filesystem has index blocks for directories, as well).
3. Implementation Details
3.1 Input and Output
You will write C++ code to build a program (FileAllocDriver.exe) that simulates indexed allocation using the
LinkedList ADT class. The program should be able to process the following five tasks upon receiving the file
allocation command from an input file or interactively from the user.
The program will be invoked in one of two ways:
1. FileAllocDriver.exe -f <filename> invokes the non-interactive mode of the program wherein the
commands the program is to execute are contained in the text file given by the variable
<filename> (“<” and “>” represent a variable). An example input file is: