【问题标题】:Convert virtual address to physical address [closed]将虚拟地址转换为物理地址[关闭]
【发布时间】:2018-12-04 04:51:44
【问题描述】:

假设我们有 28 位虚拟地址空间和 32 位物理地址空间。帧大小为1kb。我想将虚拟地址0x000039A 转换为物理地址。

[我的尝试]1kb = 1024byte = 2^10 所以虚拟页码是0x0000,偏移量是0x39A。在这个页表中,0x000x0100 物理页号。所以我认为物理地址号是 0x010039A 但答案是 0x0004039A 。有人能解释一下吗?

【问题讨论】:

标签: memory memory-management operating-system


【解决方案1】:

让我们一步一步来,尽管here 的答案可以帮助你自己做。

__________
| STEP 1 |
¯¯¯¯¯¯¯¯¯¯
0x000039A is in virtual, lets convert it to binary representation

0b 0000 0000 0000 0000 0011 1001 1010
0x   0    0    0    0    3    9    A

__________
| STEP 2 |
¯¯¯¯¯¯¯¯¯¯
Calculate the number of bits needed to reference the whole 1KB

1K = 2^10

==> 10 bits are needed. Just do log2(page-size).

__________
| STEP 3 |
¯¯¯¯¯¯¯¯¯¯
Take away the first 10 bits of the binary presentation

0b 0000 0000 0000 0000 0011 1001 1010

offset = 0b 11 1001 1010
       = 0x  3   9    A 

__________
| STEP 4 |
¯¯¯¯¯¯¯¯¯¯
Get the virtual page out of what ever bits left

0b (00)(00 00)(00 00)(00 00)(00 00)
=  0x00000

__________
| STEP 5 |
¯¯¯¯¯¯¯¯¯¯
Go to the page table at the entry 0x00000, there you will find the corresponding frame number.

Suppose the page table is given: 
________________
| 0x0 | 0x0100 |
| 0x1 | 0xA    |
|  .  |        |
|  .  |        |
|     |        |
----------------

__________
| STEP 6 |
¯¯¯¯¯¯¯¯¯¯
Turn the frame number to binary representation and concatenate it to the offset

Frame                           |      offset
0x0100                          |
0b (00)(00 00)(01 00)(00 00)(00 | 11) (1001) (1010)

0x 004039A

【讨论】:

  • 非常感谢。我不了解页面大小的影响,但现在我明白了。
  • @RecklessSerenade 一切都是为了正确地重新组织位。
猜你喜欢
  • 2017-03-10
  • 1970-01-01
  • 1970-01-01
  • 2017-07-07
  • 2015-01-29
  • 2010-09-26
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多