Answer: Virtual addresses are NOT the same as physical addresses.
Each of the logical units (program text, stack, heap, etc) are are grouped by address ranges (call virtual pages) of fixed size (such as 4K bytes).
Physical memory is also grouped into the same fixed size ranges (called physical pages).
Then when a virtual page is loaded into physical memory, it can be loaded into any physical page.
Note that the physical address where a virtual page is loaded is typically NOT the same as the virtual address.
Virtual pages process 1 | |
vir add: 0x08048000 | |
vir add: 0x08049000 | |
vir add: 0x0804a000 | |
... |
Virtual pages process 2 | |
vir add: 0x08048000 | |
vir add: 0x08049000 | |
vir add: 0x0804a000 | |
... |
Physical Address | Physical Pages |
0x06000000___ | proc 1: 0x08048000 |
0x06001000___ | proc 1: 0x08049000 |
0x06002000___ | proc 2: 0x08049000 |
0x06003000___ | free |
0x06004000___ | proc 2: 0x08048000 |
0x06005000___ | free |
0x06006000___ | proc 1: 0x0804a000 |
0x06007000___ | proc 2: 0x0804a000 |
... ___ | ... |