0% found this document useful (0 votes)
18 views

File Allocation Methods

File Allocation Methods - OS

Uploaded by

supriya sundaram
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
0% found this document useful (0 votes)
18 views

File Allocation Methods

File Allocation Methods - OS

Uploaded by

supriya sundaram
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
You are on page 1/ 4
4. File Allocation Methods: File allocation methods define how the files are stored in the disk blocks. There are three methods. 1. Contiguous Allocation 2. Linked Allocation 3. Indexed Allocation ‘The main idea behind these methods is to provide: ient disk space utilization, -cess to the file blocks. |. Contiguous Allocation 1. Each file occupies a contiguous set of blocks on the disk. For example, if a file requires 5 blocks and is given a block b as the starting location, then the blocks assigned to the file will be: b, b+1, b+2,b+3,b+4. This means that given the starting block address and the length of the file we can determine the blocks occupied by the file. The directory entry for a file with contiguous allocation contains © Address of starting block © Length of the allocated portion. The file list in the following figure starts from the block 28 with length = 4 blocks. Therefore, it occupies 28,29,30,31 blocks. Directory Advantages: 1. Sequential and Direct Accesses are supported by this. For direct access, the address of the k" block of the file which starts at block b can easily be obtained as (b+k). This is extremely fast since the number of seeks are minimal because of contiguous allocation of file blocks. advantages: 1. This method suffers from internal and external fragmentation. This makes it inefficient in terms of memory utilization. 2. Increasing file size is difficult because it depends on the availability of contiguous memory at a particular instance. 4.2 Linked List Allocation In this scheme, each file is a linked list of disk blocks which can be scattered anywhere on the disk. ‘The directory entry contains a pointer to the starting and the ending file block. Each block contains a pointer to the next block occupied by the file. Example: The file ‘jeep’ in following diagram shows how the blocks are randomly distributed. The last block (25) contains -I indicating a null pointer and does not point to any other block. Directory file start end jeep 9 25 Advantages: This is very flexible in terms of file size. File size can be increased easily since the system does not have to look for availability of contiguous memory. This method does not suffer from external fragmentation. This makes it relatively better in terms of memory utilization. Disadvantages: 1 1 Because the file blocks are distributed randomly on the disk, a large number of seeks are needed to access every block individually. This makes linked allocation slower. It does not support random or direc We cannot directly access the blocks of a file. A block k of a file can be wersing k blocks sequentially (sequential access ) from the starting block of the file via block pointers. Pointers required in the linked allocation cause some extra overhead. Indexed Allocation In this scheme, a special block known as the Index block contains the pointers to all the blocks occupied by a file. Each file has its own index block. The i entry in the index block contai address of the i" file block. ‘The directory entry contains the address of the index block as shown in the following figure. is the disk file index block jeep 19 Advantages: 1. This supports direct access to the blocks occupied by the file and therefore provides fast access to the file blocks. It overcomes the problem of external fragmentation. Disadvantages: 1. The pointer overhead for indexed allocation is greater than linked allocation. 2. For very small files, say files that expand only 2-3 blocks, the indexed allocation would keep one entire block (index block) for the pointers which is inefficient in terms of memory utilization. However, in linked allocation we lose the space of only 1 pointer per block

You might also like