Consider the two-dimensional array A: int A [] [] = new int [100] [100]; where A
ID: 3842987 • Letter: C
Question
Consider the two-dimensional array A: int A [] [] = new 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 (least recently used) replacement, and assuming page frame 1 has the process in it, and the two are initially empty: a. for (int j = 0; jExplanation / Answer
A. for(int j=00;j<100;j++)
for(int i=0;i<100;i++)
A[i][j]=0;
An integer is of 2 bytes and each page is of size 200 bytes. therefore each row of array A fits exactly in a page.
this algorithm process one column at a time therefore it will generate a page fault at every inner loop iterations. the total number of page fault will be 100*100=10,000 page faults.
B.
for(int i=0;i<100;i++)
for(int j=0;j<100;j++)
A[i][j]=0;
this algorithm process one row at a time therefore it will generate page fault at every outer loop iterations.
total number of page faults will be 100.
therefore this algorithm is better than A
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.