Consider the following program fragment that deals with a table T with 17 rows…

2023

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 to screen (i is row index and j is 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. The temporary variable temp is kept in a processor register so access to temp does not involve a memory reference. The main memory is paged and holds 16 pages of size 1024 words, the page replacement policy is least recently used. If T is stored in the virtual address space in row major format. How many page faults will be encountered

  1. A.

    16,402

  2. B.

    17,408

  3. C.

    18,208

  4. D.

    18,608

Attempted by 31 students.

Show answer & explanation

Correct answer: B

The table uses row-major storage where each of the 17 rows occupies one page. Since memory holds only 16 pages, accessing all 17 rows per column causes thrashing. Every access to T[i][j] results in a page fault because the working set exceeds physical memory capacity. With 1024 columns and 17 rows, the total page faults equal 17 multiplied by 1024.

A video solution is available for this question — log in and enroll to watch it.

Explore the full course: Mppsc Assistant Professor