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$ Operating System operating-system array page-faults virtual-memory virtual-gate-test-series + – Avdhesh Singh Rana 2.6k views answer comment Share Follow Print See all 12 Comments 12 12 Comments reply Show 9 previous comments Bhagyashree Mukherje commented Nov 23, 2018 reply Follow flag Yes ma'am this row nd column majormajor I know.The question says how many page faults if " physical memory can store one page".meaning? 0 0 replyShare srestha commented Nov 24, 2018 reply Follow flag I think it will be like this , j is page number for process P1 i.e. row major and i is page number for P2 i.e. column major Now, of course we can see P2 require more pages than P1 But, P1 and P2 has same page fault That means P2 and P1 has same number of pages So, we can say for loop executing more in P2 to visit 1 page than P1 As size of page in P2= size of page in P1 1 1 replyShare Bhagyashree Mukherje commented Nov 24, 2018 reply Follow flag Finally understud to some extent😋 Thank you ma'am. 0 0 replyShare Please log in or register to add a comment.
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 OneZero answered Jul 16, 2018 • selected Dec 4, 2022 by gatecse OneZero comment Share Follow See all 2 Comments 2 2 Comments reply Arjun commented Nov 24, 2018 reply Follow flag Number of page faults in program2 for a single page = 4 How? 0 0 replyShare OneZero commented Nov 26, 2018 i edited by OneZero Nov 30, 2018 reply Follow flag @Arjun Sorry, I actually ment we can access 4 elements in a page without a page fault. 0 0 replyShare Please log in or register to add a comment.
0 0 votes The correct answer is (D) 64M om_30 answered Aug 26 om_30 comment Share Follow 0 reply Please log in or register to add a comment.
–1 –1 vote 64 DeadMann answered Dec 4, 2022 • edited Dec 5, 2022 by DeadMann DeadMann comment Share Follow See 1 comment 1 1 comment reply gatecse commented Dec 4, 2022 reply Follow flag Please do not copy paste answers 1 1 replyShare Please log in or register to add a comment.