Question: Consider the following two-dimensional array: int X[64][64]; Suppose that a system has 10 page frames and each frame is 256 words large (an integer occupies

Consider the following two-dimensional array: int X[64][64];

Suppose that a system has 10 page frames and each frame is 256 words large (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 for each code fragment. (Assume that the program instructions are not included in these calculations)

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;

Step by Step Solution

3.45 Rating (152 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

To determine which code fragment will generate the lowest number of page faults we must consider the manner in which the data is accessed in memory an... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Operating System Questions!