File Allocation Methods in Operating System

File Allcation Methods

File Allocation Methods in OS

File allocation methods are basically ways in which any file is stored in the memory block of the system. There are three types for file allocation methods –

  • Contiguous Allocation
  • Linked List Allocation
  • Indexed Allocation

The main idea behind these methods is to provide:

  • Efficient disk space utilization.
  • Fast access to the file blocks.

Contagious Allocation

In this method for any file in the memory block, it occupies a Contagious i.e. continuous set of memory blocks.

For example for file F1, if the starting address is 1 and the memory blocks required by it is 3. Then it will be stored at b[1], b[2], b[3].

Each file will have a directory entry, that will have the following information –

  1. Address of starting block
  2. Space required by file in terms of memory block

For example consider the following structure for four files – file 1, file 2, file 3, file 4.

Contagious AllocationSize or Memory Blocks ReqStarting AddressColor in Diagram
File 131Green
File 268Red
File 3216Orange
File 4723Blue

                                    contiguous allocation

As the name suggests use of linked lists is there –

Rather than the memory being continuous, it is scattered on available spaced at the disk.These are also called as chained file allocation methods.

Every directory entry will necessarily contain the pointer to the next address of memory block the file is stored at.

There are two modifications of this – 

Modification 1

The Directory entry will have the following information –

  • First memory block address
  • Last memory block

Modification 2

The Directory entry will have the following information –

  • First memory block address
  • Last memory block
  • Total blocks required by file

The total block information is used to cross check if there is any corruption in the system or not.

Modification 3

  • First memory block address

The last memory block will not have any pointer, thus indicating the end of the file.   

                                       Linked List Allocation               

Indexed Allocation

The file allocation method of choice in both Unix and Windows is the indexed allocation method. This method was championed by the Multics operating system in 1966.

The file-allocation table contains a multi-level index for each file. Indirection blocks are introduced each time the total number of blocks “overflows” the previous index allocation. Typically, the indices are neither stored with the file-allocation table nor with the file, and are retained in memory when the file is opened 


                                            Indexed Allocation