Assume that in a paging system a process is given 2 frames. The frames are 200 w
ID: 3686476 • Letter: A
Question
Assume that in a paging system a process is given 2 frames. The frames are 200 words long. Assume that all of instruction for the process fit perfectly in the first frame. A 300 by 50 two-dimensional array, A, is declared by the process and the second frame is to be used when an array element is referenced. The elements of the array fit perfectly in the appropriate number of logical pages and no other data or instructions are included in these pages – only array elements. The array is stored in ROW MAJOR. Assume that it takes a word to store a value in each array position. Consider the following loop that manipulates the array elements: for j= 0 to 49 do for i = 0 to 299 do A[i][j] =0 How many total number of page faults will be generated by the statement A[i][j] = 0 in the loop above? Answer: __50*75=3750______________________ How many total number of page faults will be generated by the statement A[i][j] = 0 in the loop above? for i= 0 to 299 do for j = 0 to 49 do A[i][j] = 100 Answer: ___75____________________ Can these answers be explained. I am lost how the 75 is being found.Explanation / Answer
There are a total of 75 pages.
Your 1st question how i got 75
see Its a 300*50 dimensional and the frames are 200 words long.
so no of pages = 300*50/200 = 75
so each time j changes a page fault will occur ie. for the first question the total number of page faults is 50*75 = 3750.
For the second question the frame wiil be like
A[0][1] ....... A[0][49]
.
.
.
A[299][0].........A[299][49]
so for this column changes but rows are same so no need to add 50. The page fault will be 75.
In the first case the rows were changing so we have to add 50.
Hope this helps.