8. Allocation Methods (1)
8. Allocation Methods (1)
FAT structure for a file consisting of disk blocks 217, 618, and
339.
• Allocating a new block to a file in FAT
Find the first 0-valued table entry
Replace the previous end of file value with the address of the
new block
The 0 is then replaced with the end-of-file value.
• Drawbacks:
Results in a significant number of disk head seeks
The disk head must move to the start of the volume to read
the FAT and find the location of the block in question, then
move to the location of the block itself.
Solution: Cache shall be used.
• Advantages: Random Access is improved
3. Indexed Allocation
• Idea:
Bringing all the pointers together into one location the index
block
• Each file has its own index block, which is an array of
storage-block addresses.
The ith entry in the index block points to the ith block of the file.
• The directory contains the address of the index block
To find and read the ith block, we use the pointer in the ith
index-block entry
• When file is created:
All pointers in the index block are set to null
When the ith block is first written, a block is obtained from the free-space
manager
Its address is put in the ith index-block entry
• Advantages
Indexed allocation supports direct access
No external fragmentation - any free block on the storage device shall be
used
• Disadvantages
Suffers from wasted space
The pointer overhead of the index block is generally greater than the
pointer overhead of linked allocation
E.g.., in case where, a file have only one/ two blocks
• Solution: Index block should be in optimal size: not too large
& too small. 3 mechanisms are used to resolve this:
Linked scheme:
An index block is normally one storage block
To allow for large files, we can link together several index blocks
Multilevel index:
This uses a first-level index block that points to a set of second-
level index blocks, which in turn points to the file blocks.
Combined scheme:
Used in UNIX-based file systems. Keeps 15 pointers of the index
block in the file’s inode.
The first 12 pointers point to direct blocks.
The next 3 to indirect blocks - single indirect, double indirect & triple
indirect block
The UNIX inode