I was reading about how Virtual Memory and Memory management works in an Operating System. I understood how each process has its own contiguous logical address space. This address space need not be contiguous in physical memory. For this purpose, paging is used. The page tables are used to do the mapping from logical address to a physical address. The logical address is divided in two parts, first part gives the logical page number, which using the page table is translated to the physical page number, and the second part is offset into that page. Thus the contents from memory are retrieved.
Virtual memory is an extension of this, where all the pages need not be in main memory, and can be brought there through page faults.
Using my understanding I solved the 4th question on this page: www.ics.uci.edu/~bic/courses/JaverOS/ch8-ex.pdf
I got my answers wrong, and I have no clue what the right answers are. This is the way I did it:
From the diagram in the question, Page table for Process P1 will look like this according to me:
0-4
1-5
2-6
3-7
So when process P1 makes a reference to 0 i.e is 0000 in 4 bit binary, we divide
it as 00|00.
Thus logical page no = 00 and offset = 00.
From the page table, we can see 0 is mapped to 4th physical frame.
Offset is also 00 here. So I get the 0th entry(offset) in the 4th frame.
The content at this memory location(i.e Frame No. 4, offset 0) is 0.
Why is this wrong? Can anyone help?