Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Consider the two-dimensional array A: int A [] [] = new7 int [100] [100]; where

ID: 3836349 • Letter: C

Question

Consider the two-dimensional array A: int A [] [] = new7 int [100] [100]; where A [0] [0] is stored at location 200, in a paged memory system with pages of size 200. A small process resides in page 0 (location 0 to 199) for manipulating the A matrix; thus, every instruction fetch will be from page 0. For three page frames, how many page faults are generated by the following array-initialization loops, using LRU replacement, and assuming page frame 1 has the process in it, and the two are initially empty: a. for (int j = 0; j

Explanation / Answer

Since pages are of size 200 bytes , and each i9nteger we know 4 bytes, So maximum integer a page can hold is 200/4 = 50 ..and One Row will require 2 pages : 100*4 = 400 means 2 pages ..So entire A needs 2*100 = 200 pages

(a)    for (int I=0; I< 100; I++)

for (int J=0; J < 100; J++)

    A[I][J]=0;

A is access in row majo r Order and we know that each row will require 2 pages , So Those 2 will results In Page fault
So that means LRU will requuire 100*2 = 200 page fault

(b)   for (int I=0; I< 100; I++)

for (int J=0; J < 100; J++)

    A[J][I]=0;

A is accessed in column major order , and it references 100 pages in each loop , So Using LRU, it will generate 100 * 100 = 10,000 page faults.