CS FundamentalsVery hardProduct company interview · GATE level

A Unix-style inode has 12 direct pointers plus single-, double- and triple-indirect pointers; blocks are 4 KB and pointers 4 bytes. With the inode already in memory and no other blocks cached, a process reads the byte at offset 50,000,000 of a large file. Through which pointer is it reached, and how many disk blocks must be read?

  1. A. The double-indirect pointer (entry 11, then entry 943); 3 block reads
  2. B. The single-indirect pointer; 2 block reads
  3. C. The double-indirect pointer (entry 10, then entry 931); 3 block reads
  4. D. The triple-indirect pointer; 4 block reads

Correct answer: C. The double-indirect pointer (entry 10, then entry 931); 3 block reads

Logical block = floor(50,000,000 / 4096) = 12,207. A block holds 1024 pointers, so blocks 0-11 are direct and 12-1035 are single-indirect. 12,207 is beyond 1035, so it is reached through the double-indirect pointer, at relative block 12,207 - 1036 = 11,171 = 10 x 1024 + 931. Reads: the double-indirect block, the single-indirect block found at its entry 10, then the data block at entry 931 of that one - 3 reads. Dividing by 4000 instead of 4096 or forgetting to subtract the 1036 earlier blocks gives the wrong entries.

More Operating Systems questions

Exams that ask this topic