You are on page 1of 1

FILE ALLOCATION IN LINKED LIST

The problems in contiguous allocation can be traced directly to the requirement that the spaces be allocated contiguously and that the files that need these spaces are of different sizes. These requirements can be avoided by using linked allocation. In linked allocation, each file is a linked list of disk blocks. The directory contains a pointer to the first and (optionally the last) block of the file. For e ample, a file of ! blocks "hich starts at block #, might continue at block $, then block %&, block %', and finally block ($. )ach block contains a pointer to the ne t block and the last block contains a *I+ pointer. The value ,% may be used for *I+ to differentiate it from block '. -ith linked allocation, each directory entry has a pointer to the first disk block of the file. This pointer is initialized to nil (the end,of,list pointer value) to signify an empty file. . "rite to a file removes the first free block and "rites to that block. This ne" block is then linked to the end of the file. To read a file, the pointers are /ust follo"ed from block to block. There is no e ternal fragmentation "ith linked allocation. .ny free block can be used to satisfy a request. *otice also that there is no need to declare the size of a file "hen that file is created. . file can continue to gro" as long as there are free blocks. +inked allocation, does have disadvantages, ho"ever. The ma/or problem is that it is inefficient to support direct,access0 it is effective only for sequential,access files. To find the ith block of a file, it must start at the beginning of that file and follo" the pointers until the ith block is reached. *ote that each access to a pointer requires a disk read. .nother severe problem is reliability. . bug in 12 or disk hard"are failure might result in pointers being lost and damaged. The effect of "hich could be picking up a "rong pointer and linking it to a free block or into another file.

You might also like