Describe in detail the three allocating modes of file blocks
Answer:
The three allocating modes of file blocks are:
- Contiguous allocation
- Linked list allocation
- Indexed allocation
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.
Advantages of Contiguous Allocation
The advantages of contiguous allocation are:
- 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: is 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.
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
There are various 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: is 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.
Advantages of Index Allocation
The advantages of index allocation are:
- The index allocation method solves the problem of external fragmentation.
- Index allocation provides direct access.
Disadvantages of Index Allocation
The disadvantages of index allocation are:
- 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.