CS FundamentalsHardGATE CS (PYQ pattern)
A Unix-style file system has 1 KB blocks, 4-byte block pointers and inodes with 12 direct, one single-indirect and one double-indirect pointer. The inode is in memory. A program reads one byte at each offset 0, 100,000, 200,000, ..., 1,000,000 (11 reads, in that order). Every index (indirect) block, once read, stays cached; data blocks are never reused. How many disk-block reads occur in total?
- A. 29
- B. 15
- C. 16
- D. 17
Correct answer: C. 16
Block = offset / 1024: 0, 97, 195, 292, 390, 488, 585, 683, 781, 878, 976. Block 0 is direct; 97 and 195 use the single-indirect block (blocks 12-267, read once). Blocks 268 and up use the double-indirect block (read once) plus second-level index (b - 268) / 256: 292-488 use child 0, 585-683 use child 1, 781-976 use child 2. Index reads = 1 + 1 + 3 = 5, data reads = 11, total 16. Without caching it would be 29.
More Operating Systems questions
- Holes in memory (in KB, in address order): 250, 240, 230, 180, 140. Processes arrive and stay resident in this order: 100, 190, 200, 150…
- A disk delivers 20 MB/s (1 MB = 10^6 bytes) to memory by DMA, 4 bytes per bus cycle. Each word transfer steals one 40 ns memory cycle from…
- Three threads each execute x = x + 1; twice on a shared int x that starts at 0 (so six increments in all). Each increment is a separate…
- A process has a 1 MB address space split into 4 segments, each paged separately; the single-level page tables together need one 8-byte…
- A process owns 100 private writable pages. It calls fork() and both processes use copy-on-write. Before either exits, the child writes to…
- A RAID 5 array has 6 disks, each able to do 150 random I/O operations per second. A small RAID 5 write costs 4 disk I/Os (read old data…