Free-Space Management: Linked List Allocation
1. Problem Parameters
Disk Capacity: $16\text{ GB} = 2^{34}\text{ bytes}$
Block Size: $2\text{ KB} = 2^{11}\text{ bytes}$
Block Number Size: $32\text{ bits} = 4\text{ bytes}$
Pointer Size: $4\text{ bytes}$ (1 per list block)
2. Step-by-Step Solution
Step 1: Calculate Total Disk Blocks
Divide total disk capacity by the block size to find the maximum number of blocks the disk can hold.
$$\frac{2^{34}\text{ bytes}}{2^{11}\text{ bytes}} = 2^{23}\text{ blocks} = 8,388,608\text{ blocks}$$
Step 2: Determine Usable Slots per Linked-List Block
Subtract the space required for the next-block pointer from the total block size, then divide by the size of a single block number.
$$\frac{2048\text{ bytes} - 4\text{ bytes (pointer)}}{4\text{ bytes (per block number)}} = 511\text{ block numbers}$$
Step 3: Calculate Required Linked-List Blocks
Divide the total number of disk blocks by the capacity of a single linked-list block. Always apply the ceiling function, as a fractional block requires a full physical block.
$$\left\lceil\frac{2^{23}}{511}\right\rceil = \left\lceil\frac{8,388,608}{511}\right\rceil = 16,417\text{ blocks}$$
The "Pointer Trap"
A common error is dividing $2048$ by $4$ to get $512$ slots. This fails to account for the mandatory $4\text{-byte}$ pointer required to link to the next block, leaving only $511$ usable slots.
3. Comparison: Bitmap vs. Linked List
For a disk of this size ($2^{23}$ total blocks), the free-space management footprint differs heavily based on the chosen method.
| Feature | Bitmap (Bit Vector) | Linked List (Empty Disk) |
| Storage Mechanism | $1\text{ bit}$ per block | $4\text{ bytes}$ per free block |
| Maximum Overhead | $2^{23}\text{ bits} = 1\text{ MB}$ | $16,417\text{ blocks} \times 2\text{ KB} \approx 32.8\text{ MB}$ |
| Overhead Type | Static: Always consumes $1\text{ MB}$ regardless of disk utilization. | Dynamic: Shrinks as the disk fills and blocks are allocated. |
| Lookup Speed | Fast contiguous scanning for multiple blocks. | Slow sequential traversal for multiple blocks. |
4. Advanced Variation: Grouping
Instead of maintaining a continuous chain where every block holds one pointer to the next, Grouping stores the addresses of $n$ free blocks inside the first free block.
This drastically reduces traversal time and the number of blocks strictly dedicated to overhead, allowing the OS to allocate large chunks of space rapidly.