将虚拟地址转换为物理地址 [英] translate virtual address to physical address

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

问题描述

下表页适用于具有16位虚拟和物理地址以及4,096字节页面的系统.引用页面后,将参考位设置为1.线程会定期将参考位的所有值清零.所有数字均以十进制提供.

The following page table is for a system with 16-bit virtual and physical addresses and with 4,096-byte pages. The reference bit is set to 1 when the page has been referenced. Periodically, a thread zeroes out all values of the reference bit.All numbers are provided in decimal.

我想将以下虚拟地址(十六进制)转换为等效的物理地址.另外,我想为页表中的相应条目设置参考位.

I want to convert the following virtual addresses (in hexadecimal) to the equivalent physical addresses. Also I want to set the reference bit for the appropriate entry in the page table.

0xE12C

0x3A9D

0xA9D9

0x7001

0xACA1

我知道答案了,但是我想知道如何获得这些答案:

I know the answers are but I want to know how can I achieve these answers:

0xE12C → 0x312C
0x3A9D → 0xAA9D
0xA9D9 → 0x59D9
0x7001 → 0xF001
0xACA1 → 0x5CA1

我找到并尝试了但这并没有太大帮助.

I found and tried This but it did not help me much.

推荐答案

假定虚拟地址长16位.
因此,虚拟地址空间中有2 ^ 16个地址.
页面大小为4 KB(页面中有4K(4 *(2 ^ 10))个地址),因此页面数将为(2 ^ 16)/(2 ^ 12)= 2 ^ 4.
要寻址每个页面,需要4位.
虚拟地址中的最高4位将表示所引用的页码,其余12位将为页面偏移.

It is given that virtual address is 16 bit long.
Hence, there are 2^16 addresses in the virtual address space.
Page Size is given to be 4 KB ( there are 4K (4 * (2 ^ 10) )addresses in a page), so the number of pages will be ( 2^16 ) / ( 2 ^ 12 ) = 2 ^ 4.
To address each page 4 bits are required.
The most significant 4 bits in the virtual address will denote the page number being referred and the remaining 12 bits will be the page offset.

要记住的一件事是页面大小(在虚拟地址空间中)始终与主存储器中的帧大小相同.因此,最后12位在物理地址中将与虚拟地址保持相同.

One thing to remember is page size (in the virtual address space ) is always same as the frame size in the main memory. Hence the last 12 bits will remain same in the physical address as that of the virtual address.

要获取主存储器中的帧地址,只需使用前4位即可.
示例:考虑虚拟地址0xACA1
在这里, A CA1中的A表示页码(10),而对应的帧号为5(0101),因此生成的物理地址将为→0x5CA1.

To get the frame address in the main memory just use the first 4 bits.
Example: Consider the virtual address 0xACA1
Here A in ACA1 denotes the page number ( 10 ) and corresponding frame no is 5 ( 0101) hence the resulting physical address will be → 0x5CA1.

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

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