了解虚拟地址和虚拟地址空间 [英] Understanding virtual address and virtual address space

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

问题描述

我读到,当程序执行像:MOV REG,1000 这样的指令时,它会将内存地址 1000 的内容复制到 REG.可以使用索引生成地址,基址寄存器、段寄存器等方式.

I read that , "When a program executes an instruction like : MOV REG,1000 , it does so to copy the contents of the memory address 1000 to REG. Address can be generated using indexing,base registers,segment registers and other ways.

这些程序产生的地址称为虚拟地址,构成虚拟地址空间."

These program generated address are called virtual address and form the virtual address space."

谁能解释一下,(这些程序生成的地址被称为虚拟地址)是什么意思?

Can anyone please explain me,what does it (These program generated address are called virtual address) mean ?

推荐答案

程序和数据以数字形式存储在内存单元中.每个存储单元都有一个唯一编号,称为地址.代表有效地址的数字范围称为地址空间.

Programs and data are stored as numbers in memory cells. Each memory cell has a unique number, called its address. The range of numbers representing valid addresses is called address space.

当程序运行时,CPU 从内存读取数据并将结果写回内存.CPU 通过指定读取或写入操作所针对的内存单元的地址,将所需的位置传达给内存.

When programs run, the CPU reads data from memory and writes results back to memory. CPU communicates the desired location to the memory by specifying the address of the memory cell targeted by a read or a write operation.

CPU 可以通过多种方式得出地址(请记住,地址只是一个数字).代表地址的数字可以在一个寄存器中,可以存储在另一个内存位置,可以通过向寄存器添加或减去偏移量来计算,等等.在所有情况下,您编译的程序都会指示 CPU 如何提出(或生成)它需要读取或写入的地址.

There are multiple ways in which the CPU can come up with an address (remember, address is only a number). The number representing the address could be in a register, it could be stored at another memory location, it could be calculated by adding or subtracting an offset to a register, and so on. In all cases your compiled program instructs CPU on how to come up with (or generate) the address it needs to read or write.

现代架构允许多个程序执行,就好像它们拥有整个逻辑地址空间一样.换句话说,多个程序可以写入相同地址的内存位置,而无需跨越彼此的结果.这是通过虚拟化地址空间来完成的:假设程序 A 和 B 在 0x1000 处生成对内存位置的写入.在操作系统的帮助下,CPU 可以对地址进行额外的调整,并将其映射物理地址对于程序 A 为 0x60001000,对于程序 B 为 0x5F001000.两者都程序认为它们写入了 0x1000 的位置,因为它们在虚拟地址空间中运行.他们的内存模型是一个从 0 开始一直到 0x000100000000 的连续块(​​假设您的系统有 4GiB 的内存可供进程使用).但这种模型之所以有效,只是因为 CPU 额外它们的逻辑地址转换为物理地址,并在程序运行过程中根据需要分配和取走.

Modern architectures let multiple programs execute as if they own the entire logical address space. In other words, several programs could write to memory location at the same address without stepping over each others' results. This is done by virtualizing the address space: let's say programs A and B generate a write to memory location at 0x1000. The CPU, aided by the operating system, could performs additional adjustments to the address, and map it to physical address 0x60001000 for program A, and to 0x5F001000 for program B. Both programs think that they wrote to the location at 0x1000, because they operate in a virtual address space. Their model of the memory is a contiguous block starting at 0 and continuing to 0x000100000000 (assuming that your system has 4GiB of memory available to processes). But this model works only because the CPU additionally translates their logical addresses to physical addresses, which are allocated and taken away as needed in the process of running the program.

因为表示地址的相同数字对程序和CPU的意义不同,所以程序的地址空间称为virtual,CPU的地址空间称为身体.

Because the same number representing an address means different things to a program and to a CPU, the address space of the program is called virtual, and the address space of the CPU is called physical.

这篇关于了解虚拟地址和虚拟地址空间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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