Question:

To keep track of free blocks in a file system, one of the two approaches is generally used, using bitmaps (bit vectors) or using linked lists. Consider that the linked list approach is used to keep track of free blocks in a file system. Assume that the disk size is \(16\) GB, block size is \(2\) KB, and block numbers used are \(32\)-bit long. A single pointer of size \(4\) bytes is used in each block of the list to point to the next block of the list. The number of blocks required to hold the free disk block numbers is ______. (answer in integer)

Note: \(1K=2^{10}\) and \(1G=2^{30}\)

Show Hint

Each 2 KB list block loses 4 bytes to its next pointer, leaving room for 511 four byte block numbers per block.
Updated On: Jul 22, 2026
Show Solution
collegedunia
Verified By Collegedunia

Correct Answer: 16417

Solution and Explanation

Step 1: Find the total number of blocks on the disk.
The disk size is \(16\) GB and each block is \(2\) KB, so the total number of blocks is
\[ \frac{16\times2^{30}}{2\times2^{10}}=\frac{2^{34}}{2^{11}}=2^{23}=8388608 \]
In the worst case, every one of these \(2^{23}\) block numbers might need to be recorded as free, so the linked list must be able to hold up to this many \(32\) bit block numbers.

Step 2: Work out how many block numbers fit in one list block.
Each block used to store the free list is \(2\) KB \(=2048\) bytes in size. Out of this, \(4\) bytes are reserved for the pointer to the next block in the list, leaving
\[ 2048-4=2044 \text{ bytes} \]
free for storing actual block numbers. Since each block number is \(32\) bits, that is \(4\) bytes, the number of block numbers that fit in one list block is
\[ \frac{2044}{4}=511 \]

Step 3: Divide the total block numbers by the capacity of one list block.
We need enough list blocks to hold all \(8388608\) block numbers, \(511\) at a time:
\[ \frac{8388608}{511}=16416.06\ldots \]
Since a fractional block is not possible, \(16416\) full blocks alone are not quite enough.

Step 4: Check the exact remainder.
\[ 511\times16416=8388576 \]
\[ 8388608-8388576=32 \]
So after filling \(16416\) blocks completely, \(32\) block numbers are still left over, and these need one more block to hold them.

Step 5: Final answer.
\[ 16416+1=16417 \]
\[ \boxed{16417} \]
Was this answer helpful?
0
0

Top GATE CS Operating System Questions

View More Questions