[理工] 恐龍OS page fault

看板Grad-ProbAsk作者 (GnCtIlike)時間11年前 (2013/02/18 23:39), 編輯推噓4(402)
留言6則, 3人參與, 最新討論串1/1
原題是這樣: 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

02/18 23:53, , 1F
array是不是以row major為主?
02/18 23:53, 1F

02/19 00:11, , 2F
額,什麼意思@@?
02/19 00:11, 2F

02/19 02:35, , 3F
如果是row major 那答案沒錯吧?!
02/19 02:35, 3F

02/19 02:39, , 4F
抱歉 我想錯了 請無視我的推文
02/19 02:39, 4F

02/19 10:49, , 5F
我也覺得解答寫反了
02/19 10:49, 5F

02/19 11:31, , 6F
了解~~ 感謝~
02/19 11:31, 6F
文章代碼(AID): #1H8ajCu2 (Grad-ProbAsk)