看板 Grad-ProbAsk 關於我們 聯絡資訊
Consider the two dimensional array A int A[][]=new int [50][50]; Where A[0][0] is at location 100,A[0][1]=102,A[0][3]=104...,in a paged system with pages of size 100 bytes. A small process is in page0(locations 0 to 99)for manipulating the matrix; thus, every instruction fecth will be form page 0 Assume that there are five pages frames; page frame 1 has the process in it and the other four are initially empty. Consider two different page replacement algrithoms: FCFS and LRU, and the following loop. for(int j=0;j<50;j++) for(int i=0;i<50;i++) A[i][j]=0; (1)列出這個迴圈的page reference string (2)對於每一個 replacement algrithms共有幾次page fault? 我的解法是: 陣列在記憶體的排列是row major,而且一列等於1個page (1) 所以page reference string是 0 1 0 2 0 3...49 0 1 0 2 0 3...49 (不確定) . . (2) 50*50=2500 第一題要怎麼看?每一次指令fetch 到底是怎樣算一次? 是for for A[][] 一次全部? 還是只有 A[][]? 指令fetch到底是抓多少,我第一題對嗎..? -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 122.124.201.111
taitin:第一題似乎要加上50,因為0是指令頁 02/22 18:53