Free Space Management in OS
Free Space Management:
Generally, the files are stored on the disk, so, Free Space Management or Disk Space Management is a major problem to the designers. If we want to allocate space for the file, we have to know what blocks on the disk are available. Thus we need a disk allocation table in addition to the file allocation table.
To keep free disk space, the file system maintains a free space list. The free space list records all the free disk blocks. To create a file, we search the free space list for the required amount of space and allocate it to the new file. This space is then removed from the free space list, when a file is deleted, its disk space is added to the free space list.
1. Bit vector or Bit table: A bit vector is a collection of bits, in which each block is represented by one bit. If the block is free, the bit is 0. If the block is allocated, the bit is 1.
2. Linked free space list: To link all the free space blocks together, keeping a pointer to the first free block. This block contains a pointer to the next free disk block and so on.
3. Indexed block list: The chained free portion is not very efficient since to traverse the first, we must read each block requiring substantial I/O time. A modification of this approach would store the address of n free blocks in the first free block. The n-1 of these are free. The last one is the disk address of another block containing the address of the other ‘n’ free blocks.