FILE ALLOCATION METHODS


Allocation refers to the process of assigning secondary storage space to files.

The file should be allocated space in such a manner so that disk space is utilized effectively and files can be accessed quickly.

The allocation method is responsible for mapping a file’s logical blocks into the actual physical blocks on the secondary storage device.

In Most of Operating Systems, The size of a physical block is a power of 2 between 512 and 4096.

There are three methods of allocating disk space to files

§  Contiguous Allocation

§  Linked Allocation

§  Indexed Allocation

Contiguous Allocation:

§  It is the simplest allocation method in which a single contiguous set of blocks is allocated to a file at the time of creation.

§  In contiguous allocation, files are assigned to contiguous areas of secondary storage.

§  A user specifies in advance the size of the area needed to hold a file to be created.

§  If the desired amount of contiguous space is not available, the file cannot be created.\

§  Contiguous Allocation supports both direct access and sequential access.

Advantages:

§  It is simple to implement because keeping track of where a blocks of files are.

§  It is reduced to remembering only one number.

§  Performance is good because entire file can be read from the disk in a single operation.

Disadvantages:

·         This method suffers from the problem of external fragmentation.

·         It is important to declare the size of the file at the time of its creation.

Linked Allocation:

§  In Linked Allocation, A file may not be allocated contiguous blocks.

§  It is also called Chained Allocation.

§  In this method, each file is a linked list of disk blocks.

§  The disk blocks may be scattered anywhere on the disk.

§  Each block contains a pointer to the next block in a list.

§  The File Allocation Table contains single entry for each file and contains size of a file, a pointer to first and the last block of the file.

Advantages:

§  In this method every block can be utilized. But it is not possible in Contiguous Allocation Method.

§  It does not suffer from the external fragmentation.

§  No need to declare the size of a file at the time of creation.

§  No need to perform Compaction.

§  Supports Sequential Access

Disadvantages:

§  Not Support to Direct Access.

§  Reading a file sequentially is easy, but random access becomes extremely slow.

§  Pointer takes space in each disk block which can be used for storing information.

§  Less reliable because if Pointers of file are lost, then the data can be lost.

Indexed Allocation:

§  The indexed allocation method is the solution to the problem of both contiguous and linked allocation.

§  This is done by bringing all the pointers together into one location called the index block.

§  The File Allocation Table contains a separate one level index for each file.

§  The Index block has one entry for each portion allocated to the file.

§  The File Index for a file is kept in a separate block, And File Allocation Table contains the address of that index block.

Advantages:

§  It is the most popular form of File Allocation and supports both sequential and direct access to the file.

§  Free block can be used for allocation.

§  It eliminates external fragmentation.

Disadvantages:

§  If the Index block is small. So, it will not be able to hold the large file of pointers.

§  The Index Table will have to keep in Main Memory to make it work properly. If the disk is small. Then it will not be able to hold the index table which can be large pointer of Index file.

Advertisements

One thought on “FILE ALLOCATION METHODS”

Give A message for us

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s