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

Directions (Q91–95): Consider the following program fragment that deals with a table T with 17 rows and 1024 columns, computing an average for each column and printing it (i is the row index and j is the column index):

for j = [0...1023] {
  temp = 0;
  for i = [0...16]
    temp = temp + T[i][j];
  print(temp / 17.0);
}

T[i][j] and temp are 32-bit floating-point values and memory is word addressable. temp is kept in a processor register, so accessing temp does not involve a memory reference. The main memory is paged and holds 16 pages of 1024 words each. The page replacement policy is least recently used (LRU). Unless stated otherwise, T is stored in the virtual address space in row-major format.

With T stored in row-major format, how many page faults will be encountered?

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

Show answer & explanation

Correct answer: B. 17,408

Explanation

Each row is one page, and each column iteration touches all 17 rows (17 pages) while only 16 frames exist. With LRU, cycling through 17 pages faults on every access: 17 × 1024 = 17,408.

More System Software and Operating System questions