GATE / CS ARCHIVE

GATE CSE 2022 / QUESTION 63

GATE CSE 2022 Q63

Operating Systems · File Systems · Full GATE CSE 2022 paper

GATE 2022, Q63 2 marks · NAT
Report issue

File Systems

Question 63, GATE 2022: A 100-block file exists in contiguous-allocation system A and linked-allocation system B. Insert one memory-resident block between original blocks 50 and 51. There is enough free space after the contiguous file; file-control blocks are in memory. If the respective disk-access counts are nA,nB, find nA+nB.
Tap to enlarge
Answer & solution

Official answer: 153

For contiguous allocation, shift original blocks 51 through 100 one position to the right, working backward. Each of the 50 blocks is read and written, costing 100 disk accesses; writing the new memory-resident block costs one more, so nA=101. For linked allocation, follow the chain by reading blocks 1 through 50, costing 50 reads. Retain block 50 and its old next pointer in memory, write the new block pointing to original block 51, and rewrite block 50 to point to the new block: two writes, so nB=52. The sum is 153. This is the usual uncached data-block I/O model, with file-control blocks already in memory and no extra metadata-flush charges.

The backward shift in A is essential: forward shifting would overwrite block 52 before reading its original contents. In B, the data of blocks 51…100 stay in place; only the predecessor’s link and new block are written. Traversing 50 blocks rather than reading all 100 is sufficient to locate the insertion point.

Original paper, page 40 · Answer key