Convert logical (virtual) address to physical address

耗尽温柔 提交于 2019-12-18 12:43:25

问题


I have the following page table of process1 :

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:


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 :)



来源:https://stackoverflow.com/questions/11655087/convert-logical-virtual-address-to-physical-address

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!