Convert logical (virtual) address to physical addr

2020-02-26 03:29发布

I have the following page table of process1 :

enter image description here

Assuming that the paging system works with 16bit addresses and page size is 4k

And I want to convert the logical address 16000 to a physical address .

I'm a little bit new in this topic so go easy on me :

Partial solution : The address 16000 fits cell number 3 in the page table , so I guess that I need to work with that cell and its stored frame - 2 .

How can I find the offset and the physical address now ?

Thanks

1条回答
家丑人穷心不美
2楼-- · 2020-02-26 04:11

In your case process 1 currently can access upto 4 * 4k bytes of virtual memory.
Generally a process can access upto 4gb of virtual memory(depending on the implementation).
Now the table you have given maps virtual memory to the actual physical address(on RAM).With each entry of page table mapping 4k of memory from virtual to physical space.
So the physical address where the address 16000 corresponds to the 3rd entry of page table which is mapped to the physical address starting from 8192(3*4096) till 12288 (8192+4096).

16000 mod 4096 =  3712(offset).

At an offset of 3172 bytes in the virtual page 2 i.e at an offset of 3172 in physical page 3 ( at address 8192) you find the data corresponding to address 16000.
All these mappings are done by the MMU(memory management unit) for every address access a process makes.
Good link to understand this concept is here.

Cheers :)

查看更多
登录 后发表回答