A table T with 17 rows and 1024 columns is stored in memory. T[i][j] and the variable temp are 32-bit floating-point values; memory is word-addressable (1 word = 1 element) and temp is kept in a processor register (no memory reference for temp). Main memory can hold only 16 pages of 1024 words each, with LRU page replacement. The following program computes and prints the average of every column:
for j = 0 to 1023:
temp = 0
for i = 0 to 16:
temp = temp + T[i][j]
print(temp / 17.0)
If T is stored in the virtual address space in row-major format, what is the main memory hit ratio?
temp = 0
for i = 0 to 16:
temp = temp + T[i][j]
print(temp / 17.0)
Pick an option to check yourself, or open the answer below.
Show answer & explanation
Correct answer: A. 0
Explanation
In row-major order each row of 1024 elements occupies exactly one page (page size = 1024 words), so T[i][j] always lies on page i. The inner loop (fixed j, i = 0..16) therefore touches pages 0,1,2,...,16 — 17 distinct pages — in the same cyclic order on every outer iteration. With only 16 frames available, this is the classic LRU worst case for a cycle of length frames+1: whenever a page is referenced again, it is always exactly the one LRU evicted on the previous pass, so every single reference is a page fault, with zero hits. Hence the main memory hit ratio is 0, option (i).More Programming Languages and Computer Graphics questions
- Using the same table T (17 rows × 1024 columns, 32-bit word-addressable entries, 16 page frames of 1024 words each, LRU) and the same colum…
- Using the same table T (17 rows × 1024 columns, 32-bit word-addressable entries, 16 page frames of 1024 words each, LRU) and the same colum…
- Using the same table T (17 rows × 1024 columns, 32-bit word-addressable entries, 16 page frames of 1024 words each, LRU) and the same colum…
- Using the same table T (17 rows × 1024 columns, 32-bit word-addressable entries, 16 page frames of 1024 words each, LRU) and the same colum…
- A virtual memory system uses the first-in-first-out (FIFO) page replacement policy and allocates a fixed number of frames to a process. Ass…
- Which of the following statement(s) is/are correct with respect to virtual memory? Statement I: Address translation is performed for every…