601 views
0 votes
0 votes
Consider a file whose size varies between $4\: KB$ and $4\: MB$ during its lifetime. Which of the three allocation schemes (contiguous, linked and table/indexed) will be most appropriate?

1 Answer

2 votes
2 votes

Contagious Allocation – 

  • This is not a preferred method for allocation if the file size varies.
  • It requires a contagious sequence of blocks large enough to handle the entire file.
  • Since the size of the file specified in this question varies, either you have to pre-allocate 4 MB of space (which could result in wastage if the file size is minimum), or the file will need to be copied whenever it grows, to a contagious block of free space.
  • Supports Random access.

Linked Allocation – 

  • This is a preferred way for the above file if random access is not needed, rather sequential access is needed.
  • This method does not require contagious blocks of free space, rather it will link new blocks whenever a new block is needed from the free blocks available.
  • Does not support Random Access.

Indexed Allocation – 

  • This is also a preferred way for the above file if random access is needed.
  • A table called Index Table is used to store all the physical addresses of the data blocks of a file.
  • Blocks can be added or removed as per needed.
  • More complex than linked allocation.
  • Overhead for storing the Index Table is huge (greater overhead than Linked Allocation).

As the question does not specify if it requires a random access or not, Linked Allocation is the most appropriate answer considering the file is accessed sequentially.

 

Related questions

1 votes
1 votes
3 answers
4
admin asked Oct 27, 2019
1,923 views
Consider a $4-TB$ disk that uses $4-KB$ blocks and the free-list method. How many block addresses can be stored in one block?