osy
osy
Principal
Dr. B. G. Gawalwad
(Government Polytechnic Washim)
Government Polytechnic Washim
Submitted by
3 Comparison Table 6
5 Conclusion 9
6 Reference 10
Introduction
1|P age
Types of File Allocation Methods
File allocation methods determine how files are stored on disk and
accessed by the operating system. Each method balances storage
efficiency, ease of access, and system performance. Below are the three
primary file allocation methods:
1. Contiguous Allocation:
In this method, each file is stored in a sequence of contiguous
memory blocks. The operating system allocates a continuous range
of blocks for each file when it is created.
How it works:
• The OS finds a contiguous block of free memory that can accommodate
the file size.
• It assigns the file to this block, storing the starting block number and the
length (number of blocks).
• The file ‘mail’ in the following figure starts from the block 19 with
length = 6 blocks. Therefore, it occupies 19, 20, 21, 22, 23,
24 blocks.
2|P age
Advantages:
• Simple to implement.
• Fast read/write operations since all blocks of the file are stored
sequentially.
• Supports direct and random access efficiently.
Disadvantages:
• Can lead to external fragmentation, as free spaces between files may
not be usable for new files.
• Difficult to extend a file if the adjacent space is already occupied.
• Requires knowing the exact file size at creation time
Example:
If a file requires 5 blocks, and blocks 10-14 are free, the file will occupy these
blocks sequentially.
2. Linked Allocation
In linked allocation, each file is represented as a linked list of disk blocks.
Each block contains data and a pointer to the next block.
How it works:
• The OS allocates blocks dynamically as the file grows.
• The starting block of the file contains a pointer to the next block, and
so on until the last block, which has a null pointer.
• The file ‘jeep’ in following image shows how the blocks are randomly
distributed. The last block (25) contains -1 indicating a null pointer and
does not point to any other block.
3|P age
Advantages:
• No external fragmentation, as any free block can be used.
• Files can grow dynamically without needing contiguous space.
Disadvantages:
• Slower access times, especially for random access, as the OS must
traverse the linked list.
• Requires additional storage for pointers in each block.
• Higher risk of data loss if a block pointer is corrupted.
Example:
A file stored in blocks 3 → 10 → 7 → 25 will have each block pointing to the next
in the sequence.
3. Indexed Allocation
Indexed allocation uses an index block to store pointers to all the data
blocks of a file. The index block acts like a table of contents for the file.
How it works:
• The OS allocates an index block for each file.
• The index block contains pointers to the file's data blocks, which can
be scattered across the disk.
4|P age
• The file’s metadata stores the location of the index block.
Advantages:
• Supports direct access, as the index block contains pointers to all
data blocks.
• No external fragmentation.
• Files can grow dynamically without affecting other files.
Disadvantages:
• Requires additional storage for the index block.
• Limited by the size of the index block (though techniques like multi-
level indexing can address this).
Example:
An index block might point to data blocks 5, 12, 20, and 33, allowing random
access to any block.
5|P age
Comparison Table
Storage Overhead None Extra space for space for index block
pointers
Suitability Files with fixed sizes Files with Files needing direct
unpredictable sizes access
Example File System Older file systems FAT (File Allocation NTFS (New
(e.g., early Unix) Table) Technology File
System)
6|P age
Real-Life Applications of File
Allocation
1. Contiguous Allocation
• Applications:
Used in read-only storage media like CD-ROMs and DVDs, where
files are written once and do not change. This ensures no
fragmentation.
Common in scenarios requiring high-speed sequential access,
such as multimedia streaming applications.
• Reason for Use:
Efficient for sequential access since all blocks of a file are stored
together.
No additional overhead for managing pointers or indices.
2. Linked Allocation
• Applications:
o Found in older file systems like FAT (File Allocation Table),
which was widely used in MS-DOS and early Windows systems.
o Often used in external storage devices like USB drives, where
files can grow dynamically.
• Reason for Use:
o Avoids external fragmentation and allows files to grow easily.
o Suitable for systems with limited memory as it does not require
contiguous space.
3. Indexed Allocation
• Applications:
o Employed in modern file systems such as NTFS (New
Technology File System) and EXT (Extended File System),
7|P age
which are common in Windows and Linux operating systems,
respectively.
o Widely used in databases and large-scale storage systems
requiring efficient random access to file blocks.
• Reason for Use:
o Provides fast direct access, making it ideal for applications with
frequent data retrieval.
o Avoids the fragmentation issues of contiguous allocation and
the slower access speed of linked allocation.
Summary of Applications
Contiguous allocation is ideal for read-only media and multimedia
applications due to its simplicity and speed. Linked allocation is better for
systems with dynamic file growth, like USB drives and older file systems.
Indexed allocation is the preferred choice for modern file systems and
databases where efficient and flexible access to file data is critical.
8|P age
Conclusion
File allocation methods are essential for organizing and managing data
on storage devices, ensuring efficient space utilization and performance in
operating systems. The three primary methods—Contiguous, Linked, and
Indexed Allocation—offer unique approaches to storing and retrieving files.
Contiguous Allocation provides fast access for sequential data but
struggles with external fragmentation and file growth, while Linked
Allocation avoids fragmentation and supports dynamic file sizes at the cost
of slower random access. Indexed Allocation, used in modern systems like
NTFS, combines direct access and file flexibility, though it requires
additional index structures. These methods balance trade-offs in memory
efficiency, access speed, and system complexity, serving diverse
applications such as multimedia, external storage, and databases.
Understanding these methods enables optimal storage system design,
critical for effective file system management.
9|P age
Reference
1. https://www.geeksforgeeks.org/file-allocation-methods/
2. https://www.tutorialspoint.com/operating_system/os_file_system.htm
3. https://learn.microsoft.com/en-us/windows-server/storage/ntfs-overview
4. https://www.studytonight.com/lostnfound.php
5. https://www.google.com/
10 | P a g e