作業系統›Ch8 虛擬記憶體
第 19 題/共 47 題
◀ OS 19/47
19. Page Fault、LRU、Array Traversal、Locality
#OS-08-019易Page FaultLRUArray TraversalLocality
題組題幹(本題:第24題,共 2 小題)點擊展開

Assume each page is 512 bytes in size and the size of an integer is 2 bytes. Consider two C programs (Program 1 & Program 2) designed to initialize all elements of a 256-by-256 two-dimensional array (called arr as below) to 0. The array is stored in row-major order; that is, the array is stored arr[0][0], arr[0][1], …, arr[0][255], arr[1][0], …. If the operating system only allocates 128 page frames on-demand to each program and adopts Least-Recently-Used (LRU) page replacement policy to manage those fames, please answer the following two questions.

How many page faults would be generated while running Program 2:

int x, y;
int [][] arr;

for (x=0; x<256; x++)
  for (y=0; y<256; y++)
    arr[x][y] = 0;

(Program 2)

📄 交大113
跳轉到第題
▤完整推導請見《WH 資工筆記 · 作業系統》Ch8 虛擬記憶體
本章題號 · 1–20 / 47