This isn’t a homework question, it was a question we went through in class but my professor lost me on the very last part. Here it is:
How large will the Virtual Memory Table be for 16GB virtual memory with a page size of 1KB?
First we determined the # of physical memory pages
= 64MB/1024 = (2^6 * 2^20)/2^10= 2^16 = 65,536
*This means we have 65,536 possible addresses, and the address block needs to be at least 16-
bits long (plus 1 bit for valid flag and 1 for dirty flag)
Second we determined the # of virtual memory pages
= (2^34)/(2^10)= 2^24
The next part, where we actually calculate the size of the VMT is were he lost me!
(2^24 * 16 bits) + (2^24 * 1 bit) + (2^242 * 1 bit) //i understand this
(2^24 * 2) + (2^21) + (2^21) =//no idea how he got these numbers
2^25+ 2^21 + 2^21 = 32MB + 2MB + 2MB= 36MB //no idea how he got this either
So the size of the VMT is 36MB apparently
So basically I understand everything up until the last 2 steps of the final part. I understand that we do “(2^24 * 16 bits) + (2^24 * 1 bit) + (2^242 * 1 bit)” because we have 2^24 VM pages each of which have 18 bits, I’m just lost as to how he simplified this further!
I don’t know if I wrote down the numbers wrong (he does have very sloppy handwriting) or what!
So any help would be greatly appreciated!
From your question:
He’s converting bits to bytes in this step. So 16-bits becomes “2”, and and the 1-bit becomes 1/8th of a byte, which is (1/(2^3)) bytes which gets 2^21 when multiplied by 2^24.
Here’s the intermediate steps:
Then converting bytes to MB gets you 32MB + 2MB + 2MB.
This is a very theoretical bounds on the size of the VMT in this setup. Packing 18-bit entries into pages isn’t very efficient for lookup (in fact, 18-bit entries don’t evenly fit into a 1k page, 455 entries take all but 2 bits of the 1k). The flag bits could be stored separately from packed 16-bit page numbers to keep alignment and density (or the problem can just be ignored and you just do the math to lookup 18-bit entries). Given how much bigger virtual memory is from the physical memory, by definition the address space will be sparse (unless you’re mapping the same page into multiple places), so this packed, linear representation will waste more space than it should. In the real world, VMTs are hierarchical, entries are tightly packed, and entries aligned to natural boundaries. Presumably you’ll get to that later in class. 🙂