0% found this document useful (0 votes)
9 views13 pages

osy

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views13 pages

osy

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 13

Government Polytechnic Washim

DEPARTMENT OF INFORMATION TECHNOLOGY


2024-25
A MICRO-PROJECT REPORT ON:

“File Allocation Methods”


Course: Operating System(OSY)
Course code: [22516] Program Name: IF5I

Guided by: - Head of Department: -


Mr. M. S. Hule Mr. U. A. Bagade
(Lecturer in Information Technology) ( Lecturer in Information Technology)

Principal

Dr. B. G. Gawalwad
(Government Polytechnic Washim)
Government Polytechnic Washim

A MICRO-PROJECT REPORT ON:

“File Allocation Methods”


Course: Operating System(OSY)
Course code: [22516] Program Name: IF5I

Submitted by

Sr. Name Roll. Enrollment no. Seat no.


No. no
1. Vipul Bhimrao Rathod 23 2200310336 294864

2. Harsh Anil Gore 24 2200310337 294865


3. Shreya Anant Rokade 45 2200310367 294886
4 Shivani Dipak Idhole 77 2200310363
TABLE OF CONTENTS

Sr.no Contents Page


no.
1 Introduction 1

2 Types of File Allocation Method 2

3 Comparison Table 6

4 Real-time application file allocation 7

5 Conclusion 9

6 Reference 10
Introduction

File allocation methods are crucial in operating systems, defining how


files are stored, managed, and accessed on storage devices like hard drives
and SSDs. When a user saves a file, the operating system must allocate
space efficiently to store the file's data while ensuring quick access and
minimal wastage of storage space.
These methods play a significant role in the overall performance of a file
system, as they directly impact how data is read and written, how
fragmented the storage becomes over time, and how much space is wasted
due to unused blocks. The efficiency of file allocation methods is vital for
reducing latency in file access, minimizing storage overhead, and improving
reliability in modern file systems.
In this project, we will explore the three primary file allocation methods:
Contiguous Allocation, Linked Allocation, and Indexed Allocation. Each
method has distinct approaches to managing files, with advantages and
disadvantages that make them suitable for different scenarios. By
understanding these methods, we can appreciate the complexities of data
management in operating systems and how they balance efficiency,
simplicity, and flexibility.
This microproject aims to delve into these methods, illustrate their working
mechanisms, compare their strengths and weaknesses, and analyze their
real-world applications in file systems.

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

Feature Contiguous Linked Allocation Indexed Allocation


Allocation
Storage Requirement Continuous blocks of Pointer in each block Index block for
memory pointers
Access Type Sequential Direct and random
Direct and random
Fragmentation No fragmentation No fragmentation
External
fragmentation
Ease of Growth Easy (blocks can be Easy (new blocks
External
scattered) can be added to the
fragmentation
index)

Access Speed Fast Slow (due to pointer Moderate (based on


traversal) index lookup)

Storage Overhead None Extra space for space for index block
pointers

Complexity Simple Moderate (managing High (managing index


pointers) blocks)

Suitability Files with fixed sizes Files with Files needing direct
unpredictable sizes access

Risk of Data Loss Low High (pointer


Moderate (index
corruption)
corruption)

Example File System Older file systems FAT (File Allocation NTFS (New
(e.g., early Unix) Table) Technology File
System)

This table provides a quick and structured overview of the strengths,


weaknesses, and use cases for each file allocation method.

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

You might also like