作者gn123 (GnCtIlike)
看板Grad-ProbAsk
標題[理工] 恐龍OS page fault
時間Mon Feb 18 23:39:53 2013
原題是這樣:
Consider the two-dimensional array A:
int A[] [] = new int [100] [100] ;
where A [0][0] is at location 200 in a paged memory system with pages
of size 200. A small process that manipulates the matrix resides in page 0
(locations 0 to 199). 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 that page frame 1 contains the process and the other two
are initially empty?
a. for (int j = 0; j < 100; j++)
for (int i = 0; i < 100; i++)
A[i] [j] = 0;
b. for (int i = 0; i < 100; i++)
for (int j = 0; j < 100; j++)
A [i] [j] = 0;
恐龍解答是: a.50
b.5000
請問一下不是應該反過來嗎??
還是我漏看什麼@@?
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 140.113.66.184
推 Bearcome:array是不是以row major為主? 02/18 23:53
→ gn123:額,什麼意思@@? 02/19 00:11
推 Bearcome:如果是row major 那答案沒錯吧?! 02/19 02:35
推 Bearcome:抱歉 我想錯了 請無視我的推文 02/19 02:39
推 wsx02:我也覺得解答寫反了 02/19 10:49
→ gn123:了解~~ 感謝~ 02/19 11:31