Free Space Management in Operating System
What is Free Space Management?
The system always keeps the records of the free disks blocks for allocating space to files when they are created. To use the space free from removing the files, free space management becomes critical. The system maintains a free space list which keeps record of the disk blocks that are not assigned to some file or directory.
When file is created, operating system searches the free space register for saving the file. During deletion the file, the computer system frees the given space and attaches this to the “free space list”.
There are four methods used in the free space management of operating system. There are as follows:
- Bitmap or Bit vector
- Linked list
- Grouping
- Counting
Bitmap or Bit vector
A bitmap is a group of bits where each bit corresponds to a disk block. It can take two values: 0 and 1, where 0 indicates that the block is allocated and 1 indicates the free block. This is the most common method used to implement the free space list. In this method, each block in the hard disk is implemented by a bit.
Advantages of Bit vector
Advantages of bit vector are as follows:
- It is simple and easy to understand.
- It consumes less memory.
- It is well organized to find free space.
Disadvantages of Bit vector
Disadvantages of bit vector are as follows:
- OS goes through the all blocks unless it finds a free block.
- To find a free block, OS may need to search the entire bit vector.
- It requires a special hardware support in some conditions.
Linked list
In this method, the free disk blocks are attached together. A free block carries a pointer to the next free block. The block number of the very first disk block is collected at a separate location on disk and also cached in memory. This method has a major disadvantage that it requires for free space list traversal. This entire process is known as linked list.
Advantages of linked list
Advantages of linked list are as follows:
- In this method, accessible space is used effectively.
- As there is no size limit on a linked list, new space can be allocated easily.
Disadvantages of linked list
Disadvantages of linked list are as follows:
- In this method, the overhead of maintaining the pointer appears.
- The linked list is not efficient when we need to reach each block of the memory.
Grouping
This is also an important method for free space management. In this method, there is a modification of free list takes place which stores the address of the n free blocks. In grouping, the initial n-1 blocks are free but the last block carries the address of n blocks. When we use the standard linked list, the address of the higher number of blocks can be found very quickly. In grouping, we cannot keep a list of n free disk addresses but we keep address the initial free block. This whole process is known as grouping.
Advantages of grouping
Advantages of grouping are as follows:
- The address of higher number of free blocks can be found very quickly.
- Grouping is a type of method which has a benefit of making it simple to locate the addresses of collection of empty disk blocks.
- The modification of free list takes place that’s why there is no need to pass over the whole list.
Disadvantages of grouping
Disadvantages of grouping are as follows:
- The major disadvantage of grouping method is that the space of block is wasted in storing addresses. Nth block is used to collect the addresses of next free blocks.
- Addresses of initial free blocks can be saved but we are not able to maintain the list of all n free disk addresses.
- It is very costly in maintaining the index of blocks.
Counting
Here, counting is the last method of free space management in operating system. This method is also used in the modification of the linked list method. This method has an advantage most of contiguous blocks can be freed concurrently. In this type of method linked list is maintained as well as the pointer to the next free block that come after first block is also preserved. There is no need to traverse the whole list. This whole process is known as counting.
Advantages of counting
Advantages of counting are as follows:
- Fast allocation of higher number of consecutive free blocks.
- Random access to the free block can be performed.
- Entire list is generally smaller in size.
Disadvantages of counting
Disadvantages of counting are as follows:
- Every free block requires huge space to keep the count in the disk.
- To perform traversal operations, we have to store the entries in B-tree.
- Whole area got reduced in counting.