GATE / CS ARCHIVE

GATE CSE 2025 SET 1 / QUESTION 51

Separating linked-allocation overhead from fragmentation

Operating Systems · File Systems · Full GATE CSE 2025 Set 1 paper

GATE 2025 Set 1, Q51 2 marks · NAT
Report issue

File Systems

Question 51, GATE 2025: A 512 MiB disk uses 64 KiB blocks. Linked allocation reserves four bytes in every allocated block for a next-block pointer, including a four-byte NULL pointer in the last block. A file holds 1 MiB of data. With K=2^10 and M=2^20, how many bytes are unused because of internal fragmentation?
Tap to enlarge
Answer & solution

Official answer: 65468

Approach: Subtract pointer storage from per-block data capacity before computing how many blocks are needed.
A block is 64×1024=65536 bytes. Four bytes are reserved for the pointer, leaving 65532 bytes for file data. The file has 1048576 bytes. Sixteen blocks can hold only 16×65532=1048512 data bytes, which is 64 bytes too little. Therefore a seventeenth block is necessary.
The first sixteen data regions are full and the last contains the remaining 64 file bytes. Its unused data area is 65532−64=65468 bytes. Equivalently, 17×65532−1048576=65468.
The 17 pointer fields occupy 68 bytes, but those bytes are allocated structural overhead rather than unused data space. Counting total physical allocation minus file size would give 17×65536−1048576=65536; subtracting the pointer overhead leaves the required 65468. The last NULL pointer still consumes its specified four bytes.

Original paper, page 51 · Answer key