File allocation methods are:
Contiguous Allocation method
Linked Allocation method
Indexed Allocation method
Contiguous Allocation
The contiguous allocation method requires each file to occupy a set of contiguous address on the disk.
Disk addresses define a linear ordering on the disk.
With this ordering, accessing block b+1 after block b normally requires no head movement.
Contiguous allocation of a file is defined by the disk address and the length of the first block. If the file is n blocks long, and starts at location b, then it occupies blocks b, b+1, b+2, …, b+n-1.
The directory entry for each file indicates the address of the starting block and the length of the area allocated for this file
linked Allocation:
In this method, each file occupies disk blocks scattered anywhere on the disk.
It is a linked list of allocated blocks.
When space has to be allocated to the file, any free block can be used from the disk and system makes an entry in directory.
Directory entry for allocated file contains file name, a pointer to the first allocated block and last allocated block of the file.
The file pointer is initialized to nil value to indicate empty file.
A write to a file, causes search of free block.
After getting free block data is written to the file and that block is linked to the end of the file.
To read the file, read blocks by following the pointers from block to block starting with block address specified in the directory entry.
For example, a file of five blocks starting with block 9 and continue with block 16,then block 1,then block 10 an finally block 25.each allocated block contains a pointer to the next block.
Indexed Allocation:
In this method, each file has its own index block.
This index block is an array of disk block addresses.
When a file is created, an index block and other disk blocks according to the file size are allocated to that file.
Pointer to each allocated block is stored in the index block of that file.
Directory entry contains file name and address of index block.
When any block is allocated to the file, its address is updated in the index block.
Any free disk block can be allocated to the file. Each ith entry in the index block points to the ith block of the file. To find and read the ith block, we use the pointer in the ith index block entry.
0 Comments