将逻辑(虚拟)地址转换为物理地址 [英] Convert logical (virtual) address to physical address

查看:374
本文介绍了将逻辑(虚拟)地址转换为物理地址的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下process1页表:

假定分页系统使用16bit地址,并且页面大小为4k

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

我想将逻辑地址16000转换为物理地址.

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 :

部分解决方案:地址16000符合页表中的单元格编号3,所以我猜 我需要使用该单元格及其存储的框架-2.

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 ?

谢谢

推荐答案

在您的情况下,进程1当前可以访问最多4 * 4k字节的虚拟内存.
通常,一个进程最多可以访问4GB的虚拟内存(取决于实现方式).
现在,您给定的表将虚拟内存映射到实际的物理地址(在RAM上).页面表的每个条目将4k的内存从虚拟空间映射到物理空间.
因此,地址16000对应于页表的第3个条目的物理地址,该表映射到从8192(3*4096) till 12288 (8192+4096)开始的物理地址.

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

在虚拟页2中偏移量为3172字节的位置,即在物理页3中偏移量为3172字节(地址8192)处,您找到对应于地址16000的数据. 所有这些映射都是由MMU(内存管理单元)针对进程进行的每个地址访问完成的.
此处是了解该概念的良好链接.

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.

干杯:)

这篇关于将逻辑(虚拟)地址转换为物理地址的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆