All mock tests are FREE till 31 December — register to save your progress

Using the same table T (17 rows × 1024 columns, 32-bit word-addressable entries, 16 page frames of 1024 words each, LRU) and the same column-averaging program as above, now consider T stored again in column-major format. What is the main memory hit ratio?
for j = 0 to 1023:
  temp = 0
  for i = 0 to 16:
    temp = temp + T[i][j]
  print(temp / 17.0)

Pick an option to check yourself, or open the answer below.

Show answer & explanation

Correct answer: D. 99.9%

Explanation

From the column-major analysis above, the program makes 17×1024 = 17,408 total memory references and causes only 17 page faults (one per page, on the first word of each page, since the sweep is strictly sequential and never revisits a page). So hits = 17,408 − 17 = 17,391, and the hit ratio = 17,391 / 17,408 ≈ 0.99902, i.e. about 99.9%. This matches option (iv), and contrasts sharply with the 0% hit ratio of the row-major layout, showing how badly access-pattern/storage-order mismatches can hurt paging performance.

More Programming Languages and Computer Graphics questions