The Gateway to Computer Science Excellence
0 votes

Consider the following two-dimensional array:

int X[64][64];

Suppose that a system has four page frames and each frame is $128$ words (an integer occupies one word). Programs that manipulate the $X$ array fit into exactly one page and always occupy page $0.$ The data are swapped in and out of the other three frames. The $X$ array is stored in row-major order $(i.e., X[0][1]$ follows $X[0][0]$ in memory$).$ Which of the two code fragments shown below will generate the lowest number of page faults? Explain and compute the total number of page faults.

Fragment A
for (int j = 0; j < 64; j++) 
     for (int i = 0; i < 64; i++) X[i][j] = 0;

Fragment B 
for (int i = 0; i < 64; i++) 
     for (int j = 0; j < 64; j++) X[i][j] = 0;
in Operating System by Veteran (58.8k points) | 5 views

Please log in or register to answer this question.

Related questions

Quick search syntax
tags tag:apple
author user:martin
title title:apple
content content:apple
exclude -tag:apple
force match +apple
views views:100
score score:10
answers answers:2
is accepted isaccepted:true
is closed isclosed:true
50,737 questions
57,291 answers
104,890 users