File Allocation in OS
Allocation Method
Each file allocation method has its advantages and disadvantages. Mainly a system uses one method for all files within the system.
- Contiguous allocation
- Linked allocation
- Indexed allocation
The main idea behind contiguous allocation methods is to provide
- Efficient disk space utilization
- Fast access to the file blocks
Contiguous allocation
- Each file in the disk occupies a contiguous address space on the disk.
- In this scheme, the address is assigned in the linear fashion.
- The is very easy to implement the contiguous allocation method.
- In the contiguous allocation technique, external fragmentation is a major issue.
Advantages:
- In the contiguous allocation, sequential and direct access both are supported.
- For the direct access, the starting address of the kth block is given and further blocks are obtained by b+K,
- This is very fast and the number of seeks is minimal in the contiguous allocation method.
Disadvantages:
- Contiguous allocation method suffers internal as well as external fragmentation.
- In terms of memory utilization, this method is inefficient.
- It is difficult to increase the file size because it depends on the availability of contiguous memory.
Linked allocation
Advantages:
- In terms of the file size, this scheme is very flexible.
- We can easily increase or decrease the file size and system does not worry about the contiguous chunks of memory.
- This method free from external fragmentation this makes it better in terms of memory utilization.
Disadvantages:
- In this scheme, there is large no of seeks because the file blocks are randomly distributed on disk.
- Linked allocation is comparatively slower than contiguous allocation.
- Random or direct access is not supported by this scheme we cannot access the blocks directly.
- The pointer is extra overhead on the system due to the linked list.
Indexed Allocation
Advantages:
- This scheme supports random access of the file.
- This scheme provides fast access to the file blocks.
- This scheme is free from the problem of external fragmentation.
Disadvantages:
- The pointer head is relatively greater than the linked allocation of the file.
- Indexed allocation suffers from the wasted space.
- For the large size file, it is very difficult for single index block to hold all the pointers.
- For very small files say files that expend only 2-3 blocks the indexed allocation would keep on the entire block for the pointers which is insufficient in terms of memory utilization.