物理寻址和虚拟寻址概念之间的区别

Ren*_*h G 23 memory-management cpu-architecture

这是重新提交,因为我没有收到来自superuser.com的任何回复.很抱歉对于这个误会.

我需要了解嵌入式系统中物理寻址和虚拟寻址概念之间的区别.

为什么在嵌入式系统中实现虚拟寻址概念?

在嵌入式系统中,具有物理寻址概念的系统的虚拟寻址有什么优势?

如何在嵌入式系统中完成虚拟寻址到物理寻址之间的映射?

请在一些简单的架构中用一些简单的例子解释上述概念.

Bor*_*lid 47

物理寻址意味着您的程序实际上知道RAM的真实布局.当您访问地址0x8746b3处的变量时,它就是存储在物理RAM芯片中的变量.

通过虚拟寻址,所有应用程序内存访问都转到页表,然后从虚拟映射到物理地址.因此每个应用程序都有自己的"私有"地址空间,没有程序可以读取或写入另一个程序的内存.这称为分段.

Virtual addressing has many benefits. It protects programs from crashing each other through poor pointer manipulation, etc. Because each program has its own distinct virtual memory set, no program can read another's data - this is both a safety and a security plus. Virtual memory also enables paging, where a program's physical RAM may be stored on a disk (or, now, slower flash) when not in use, then called back when an application attempts to access the page. Also, since only one program may be resident at a particular physical page, in a physical paging system, either a) all programs must be compiled to load at different memory addresses or b) every program must use Position-Independent Code, or c) some sets of programs cannot run simultaneously.

The physical-virtual mapping may be done in software (with hardware support for memory traps) or in pure hardware. Sometimes even the page tables themselves are on a special set of hardware memory. I don't know off the top of my head which embedded system does what, but every desktop has a hardware TLB (Translation Lookaside Buffer, basically a cache for the virtual-physical mappings) and some now have advanced Memory Mapping Units that help with virtual machines and the like.

The only downsides of virtual memory are added complexity in the hardware implementation and slower performance.

  • @Renjith G:一般来说,特定的物理页面只映射到一个应用程序的虚拟空间,因此程序无法相互干扰.如果明确分配共享内存,则两个不同应用程序的虚拟页面将映射到同一页面.但是,在一般情况下,应用程序的物理页面集是不相交的.从虚拟到物理的映射是**每个应用程序**并且当您进行上下文切换时刷新TLB. (4认同)