CS FundamentalsVery hardGATE CS (PYQ pattern)

A 512 x 512 matrix of 4-byte integers is stored row-major, starting at a page boundary, with 4 KB pages (so two rows per page). The code sums it column by column (for j { for i { s += a[i][j]; } }). The data TLB is fully associative with 128 entries and strict LRU, and only the matrix pages compete for it (the TLB starts empty). How many TLB misses occur for the matrix?

  1. A. 262144
  2. B. 256
  3. C. 131072
  4. D. 65536

Correct answer: C. 131072

A column pass visits rows 0..511 in order, i.e. the 256 pages cyclically, two consecutive accesses per page. With 128 LRU entries each page is evicted before the next pass, so every page costs 1 miss (then 1 hit): 256 x 512 = 131072. A 256-entry TLB would give only 256 misses; 262144 forgets that two rows share a page.

More Operating Systems questions

Exams that ask this topic