Pergunta

I've looked at a few different articles related to this already but none of them explain the solution in a way that I can understand and replicate. I need to know how to translate a physical address to a virtual address in memory based on the following:

A simple virtual memory system has 32KB physical memory with 16-bit virtual address, of which 12 bits are used as offset. The following is the current content of the page table of one of the processes:

enter image description here

So basically I think the page size of this virtual memory system is 1024KB. I need a process to find the corresponding PA of VA B2A0. If you can give me the process I can go from there, you don't have to give me the final solution :)

Thanks in advance guys. Also, if you know of an article that does this already and I've just missed it, feel free to just link me to that.

Cheers.

Foi útil?

Solução

32 KB is 2^15. so there are 15 bits for every physical address, lower 12 of them are used as offset, higher 3 as a number of pageframe.

What virtual page does 0xb2a0 resides in? To determine this, we need to take bits of the address, higher than 2^12. The size of a page is 2^12, that is 4096 or 0x1000, so it is a virtual page number 0xb = 11 (floor of 0xb2a0 / 0x1000). Offset inside the page is 0xb2a0 modulo 0x1000, it's 0x2a0.

Then use the table to translate the virtual page number 11 to a physical pageframe. The virtual page is present (1), and it corresponds to the physical frame number with higher bits 111, that is 111 + twelve 0 in binary, => 0x7000 - it is the address of the start of the physical frame.

Our physical address resides at offset 0x2a0, so, the sought physical address is 0x7000 + 0x2a0 = 0x72a0.

Please, follow this flow and make it clear for you. If you have questions, read the Wikipedia first and if something is still not clear, ask :)

Outras dicas

I was trying to do my examination review and study, and I couldn't find a solid answer to this same question. I consolidated what I have learnt, and I hope that whatever I summed up here will help those like me. :)

I find the explanation in the answer above a little hard to understand for my little brain.

I think this link below gives a better overview than Wikipedia's explanation: http://williams.comp.ncat.edu/addrtrans.htm

This youtube video also offers an excellent guide in explaining the process of virtual address translation: https://www.youtube.com/watch?v=6neHHkI0Z0o

Back to the question ->>>

The first question is - what is the 'page size' of this virtual memory system? based on the definition here - https://en.wikipedia.org/wiki/Page_(computer_memory)

I was initially confused between 'pages' and 'page size' but I kinda figured it out now. Pages determines the number of pages available (like in a book), and page size is like (A4,A5,A6 pages in the book!).

As such, since the virtual memory and physical memory offset is the same and is mapped accordingly, we can determine the page size via the offset size. If the offset size is given as 12-bit, then 2^12 = 4,096 Byte a.k.a 4-KB.

Side question for curious minds, how many virtual memory pages are there? - 16-bit of virtual address space minus 12-bit of offset = 4-bit - which equals to 2^4 = 16-pages available (thus the table we see!)

Another side question for other curious minds, how many PHYSICAL memory pages are there? - 32KB of physical Memory = 32 x 1024bytes = 32,768 bytes - Log(32768) / Log(2) = 15-bits which also means 2^15 for total physical MEMORY - minus the offset of 12-bit that we already know... - 15-bit (total physical memory) minus 12-bit (offset) = 3-bit for physical address space

Going to the next question, what is the corresponding physical address of virtual address 0xb2a0 (that is currently set in hex notation)?

@Dmytro Sirenko answer above explains it quite well, I will help to rephrase it here.

We need to remember that our virtual address is - 16-bit, and that address space now contain is value = b2a0 (ignoring the 0x).

My short-cut (please correct me if am wrong), is that since the ratio of the address : offset (page size) is 4:12 = 1:3...

b            |  2  a  0
^
page number  |  offset

When converting hex value b to decimal = 11.

I look into the table, and I found Page Frame = 111 in the table entry number 11.

111 is noted in binary and it correlates to the physical memory frame.

Remember, we were looking at 15-bit of Physical Memory Address space, as such, we can determine that:

1 1 1    |   0 0 0 0 0 0 0 0 0 0 0 0 
Address  |   offset

As Offset are mapped directly from virtual memory to physical memory, we bring the value of (2a0) right into the physical memory. Unfortunately, we can't represent it right away in here because it's in hexadecimal format while my above address space is set in binary.

Considering that I am going to be tested in an examination and I won't be allowed to bring in a calculator... I will do a reverse and answer in Hexadecimal instead. :)

When we convert 111 into decimal (I go by 001 = 1, 010 = 2, 100 = 4, 101 = 5, 110 = 6, 111 = 7). Now I need to convert from decimal to Hex! = 7 (dec) = 7

As such, the corresponding Physical Memory location of this virtual memory address is.... (loud drums and curtain open....)

7 2 a 0

which is notated in this manner 0x72a0.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top