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

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

问题描述

我读到,当程序执行诸如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天全站免登陆