CS FundamentalsVery hardGATE CS

int A[128][128] (4-byte ints) is stored row-major in pages of 512 bytes; the array starts on a page boundary and the process has only 2 frames for A (initially empty, LRU). The loop is `for j in 0..127: for i in 0..127: A[i][j] = 0;`. How many page faults occur?

  1. A. 128
  2. B. 64
  3. C. 8192
  4. D. 16384

Correct answer: D. 16384

Each row is 512 bytes = exactly one page, so A occupies 128 pages. Traversing column-wise touches a different page on every access (row i), and 2 frames cannot hold 128 rows, so all 128 × 128 = 16384 accesses fault. Row-wise traversal would fault only 128 times.

More Operating Systems questions

Exams that ask this topic