• edited by
2,649 views
3 3 votes

Suppose a $32 K×8 K$ matrix A with $1$-byte elements is stored in row major order in virtual memory. Assume that only the program in question occupies space in physical memory.
Program $1$

for (i = 0; i < 32768; i++)
   for (j = 0; j < 8192; j++)
       A[i][j] = A[i][j] * A[i][j];



Program $2$

for (j = 0; j < 8192; j++)
 for (i = 0; i < 32768; i++)
      A[i][j] = A[i][j] * A[i][j];



If both program $1$ and program $2$ causes $8 K$ page faults, how many page faults would program $2$ experience if the physical memory can store only $1$ page?

$(A) 8M$
$(B) 16M$
$(C) 32M$
$(D) 64M$

3 Answers

Best answer
1 1 vote

Given a matrix of size 32K*8K

also given that the page fault of both are equal, which is only possible if the whole matrix can be stored in memory.

Further its mentioned that the number of page fault is 8K which means the page size is 32K

Now we need to find out the number of page fault caused by program2 with page size 32K

Number of accesses in program2 for a single page = 4

for each iteration of for(i = 0; i < 32768; i++) loop there will be 32K/4 page faults = 8K page faults

This is repeated for(j = 0; j < 8192; j++) number of times.

Hence total number of page faults = 8K*8K = 64M

Option D is the correct answer

• selected by
Position:
Show:

Related questions

1 1 vote
0 0 answers
886
886 views
Samujjal Das asked Jan 24, 2017
886 views
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...
2 2 votes
0 0 answers
526
526 views
anupamsworld asked Aug 19, 2025
526 views
Assume that an OS uses a two-level page table setup with the following attributes: 32-bit address space, size of each PTE to be 4 bytes and page size of 4KB. Further, a p...
3 3 votes
1 1 answer
1.8k
1.8k views
tp21 asked Sep 22, 2019
1,803 views
To calculate EMAT in case of page fault we used:EMAT= page fault rate*(page fault service time) + (1-page fault rate)*(memory access time)My doubt is:In case of NO PAGE ...
0 0 votes
1 1 answer
7.1k
7.1k views
akash.dinkar12 asked Mar 21, 2019
7,103 views
Consider the following page reference string:$7, 2, 3, 1, 2, 5, 3, 4, 6, 7, 7, 1, 0, 5, 4, 6, 2, 3, 0 , 1.$Assuming demand paging with three frames, how many page faults ...