0% found this document useful (0 votes)
168 views

File Allocation Methods

Uploaded by

Vaibhavi Kamble
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
168 views

File Allocation Methods

Uploaded by

Vaibhavi Kamble
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 14

OPERATING SYSTEM

FILE ALLOCATION METHODS


FILE ALLOCATION
• The allocation methods define how the files are stored
in the disk blocks.
• There are three main disk space or file allocation
methods.
• Contiguous Allocation
• Linked Allocation
• Indexed Allocation
• The main idea behind these methods is to provide:
• Efficient disk space utilization.
• Fast access to the file blocks.
CONTIGUOUS ALLOCATION
• Contiguous allocation is one of the most used methods for
allocation.
• Contiguous allocation means we allocate the block in such
a manner, so that in the hard disk, all the blocks get the
contiguous physical block.
• We can see in the below figure that in the directory, we
have three files.
• In the table, we have mentioned the starting block and the
length of all the files.
• We can see in the table that for each file, we allocate a
contiguous block.
EXAMPLE
Advantages of Contiguous Allocation

• The contiguous allocation method gives


excellent read performance.
• Contiguous allocation is easy to implement.
• The contiguous allocation method supports
both types of file access methods that are
sequential access and direct access.
• The Contiguous allocation method is fast
because, in this method number of seeks is less
due to the contiguous allocation of file blocks.
• Disadvantages of Contiguous allocation
• The disadvantages of contiguous allocation
method are:
• In the contiguous allocation method,
sometimes disk can be fragmented.
• In this method, it is difficult to increase the
size of the file due to the availability of the
contiguous memory block.
Linked List Allocation
• The linked list allocation method overcomes the drawbacks of
the contiguous allocation method.
• In this file allocation method, each file is treated as a linked list
of disks blocks.
• In the linked list allocation method, it is not required that disk
blocks assigned to a specific file are in the contiguous order on
the disk.
• The directory entry comprises of a pointer for starting file block
and also for the ending file block.
• Each disk block that is allocated or assigned to a file consists of
a pointer, and that pointer point the next block of the disk,
which is allocated to the same file.
EXAMPLE
Advantages of Linked list allocation

• There are various advantages of linked list allocation:


• In liked list allocation, there is no external
fragmentation. Due to this, we can utilize the memory
better.
• In linked list allocation, a directory entry only
comprises of the starting block address.
• The linked allocation method is flexible because we
can quickly increase the size of the file because, in
this to allocate a file, we do not require a chunk of
memory in a contiguous form.
Disadvantages of Linked list Allocation
• Linked list allocation does not support direct
access or random access.
• In linked list allocation, we need to traverse
each block.
• If the pointer in the linked list break in linked
list allocation, then the file gets corrupted.
• In the disk block for the pointer, it needs some
extra space.
Indexed Allocation

• The Indexed allocation method is another method


that is used for file allocation.
• In the index allocation method, we have an
additional block, and that block is known as the
index block.
• For each file, there is an individual index block. In
the index block, the ith entry holds the disk address
of the ith file block.
• We can see in the below figure that the directory
entry comprises of the address of the index block.
EXAMPLE
Advantages of Index Allocation

• The index allocation method solves the


problem of external fragmentation.
• Index allocation provides direct access.
Disadvantages of Index Allocation

• In index allocation, pointer overhead is more.


• We can lose the entire file if an index block is
not correct.
• It is totally a wastage to create an index for a
small file.

You might also like