作者christianSK (AG)
看板Grad-ProbAsk
標題Re: [理工] [OS] page fault
時間Fri Jun 17 10:31:07 2011
※ 引述《mqazz1 (無法顯示)》之銘言:
: consider the two-dimensional array A;
: int A[100][200];
: 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 (locations 0 to 199) for manipulating the A
: matrix;
: thus, every instruction fetch will be from page 0
: for four page frames, how many page faults are generated by the following
: array-initialization loops,
: using FIFO replacement, and assuming page frame 0 has process in it,
: and the other three are initially empty
: (1)
: for (j=0; j<50; j++)
: for(i=0; i<100; i++)
: A[j][i]=0;
: (2)
: for (j=0; j<50; j++)
: for(i=0; i<100; i++)
: A[i][j*4]=0;
: (3)
: for (j=0; j<50; j++)
: for(i=0; i<100; i++)
: A[j*2][i*2]=0;
: 請問這題該怎麼算呢?
: 謝謝
三個小題看起來差不多, 容許我只做第一小題
題目說有一個process負責處理矩陣的運算, 座落在mem[0-199], 也就是占用一個frame
那就剩下三個frame
假設, 題目是row-major, 而一個int 占用4個bytes,
那麼每50次存取會產生一次page fault, 而第一小題要對矩陣作5000次存取, 所以會產生
100次的page fault, 如果再加上把process load進來的那次就是101次page fault
這是我的想法, 有錯請大家指正
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 111.243.151.215
推 mqazz1:謝謝! 可以順便請問2跟3題嗎? 06/17 10:58
→ mqazz1:2變成column major而且index有變 06/17 10:59
→ mqazz1:3是row和column的index都有跳.. 06/17 10:59