1
votes

I am currently working some exercises regarding the concept of virtual memory. However, I am not sure if I understand it right or if the question is so trivial that I am just worrying too much:

A system is working on 20 bit wide virtual addresses. Page size is 4096 Byte and one-level paging is used.
a) What's the size of the virtual address-space?
b) What's the size of the addressable physical memory?

I'd say the answer is the same for both questions, it's 2^20 Byte. I can't address more physical memory than there is virtual address-space.

2
Please read Under what circumstances may I add “urgent” or other similar phrases to my question, in order to obtain faster answers? - the summary is that this is not an ideal way to address volunteers, and is probably counterproductive to obtaining answers. Please refrain from adding this to your questions.halfer

2 Answers

2
votes

In general (as an answer to a class question that is), you are quite right (*). Your addressable physical memory is the same size as your virtual.

That's the point of V2P translation in the first place. Also, think: If your virtual address was more, then in your program you may had allocated space that would never reach RAM, so that would be useless, let alone catastrophic. On the other side, if you could map more addresses than you had in your virtual memory, then physical spaces would go to waste, so there is no point on that, too.

Lastly, to be completely sure, you could actually do the translation yourself and count:
From those 20 bits you need 12 of those to map addresses within the same page (as 2^12 = 4096 which is the size of your page) and you can use the 8 bits left to enumerate / map PTEs in your Page Table. So, you can have 2^8 = 256 PTEs, and each entry "has" a page of 4096 Bytes, so in total you have (2^8) * (2^12) = 2^20 Bytes, same as you computed.

Edit: The translation process I described applies only to one-level pages tables as asked in the question. Two-level paging which is the norm today needs another in between step.

(*): See user3344003's answer and comments though, that provides some more information on why this isn't always the case

1
votes

Actually some systems DO allow a larger physical address space than the virtual address space. 32-bit Intel is one example.

A process can only access range of memory limited by the bits in an address but the system can access larger ranges of memory in the same number of bits by using pages of bytes.