Search code examples
operating-systemmemory-addresspage-tables

Is my understanding of the relationship between virtual addresses and physical addresses correct?


I've been researching (on SO and elsewhere) the relationship between virtual addresses and physical addresses. I would appreciate it if someone could confirm if my understanding of this concept is correct.

The page table is classified as 'virtual space' and contains the virtual addresses of each page. It then maps to the 'physical space', which contains the physical addresses of each page.

A wikipedia diagram to make my explanation clearer:

https://upload.wikimedia.org/wikipedia/commons/3/32/Virtual_address_space_and_physical_address_space_relationship.svg

Is my understanding of this concept correct?

Thank you.


Solution

  • Not entirely correct.

    Each program has its own virtual address space. Technically, there is only one address space, the physical random-access memory. Therefore it's called "virtual" because to the user program it seems as if it has its own address space.

    Now, take the instruction mov 0x1234, %eax (AT&T) or MOV EAX, [0x1234] (Intel) as an example:

    1. The CPU sends the virtual address 0x1234 to one of its parts, the MMU.
    2. The MMU obtains the corresponding physical address from the page table. This process of adjusting the address is also lovingly called "massaging."
    3. The CPU retrieves the data from the RAM location the physical address refers to.

    The concrete translation process depends heavily on the actual architecture and CPU.