简体   繁体   English

线性、物理、逻辑和虚拟 memory 地址有什么区别?

[英]What is the difference between linear ,physical ,logical and virtual memory address?

I am trying to read Intel software developer manual to gain some understanding how operating system works and these four addressing terms is confusing me.我正在尝试阅读英特尔软件开发人员手册以了解操作系统的工作原理,而这四个寻址术语让我感到困惑。 Here is what i have understood, correct me if I am wrong.这是我理解的,如果我错了,请纠正我。

linear address : What appear to a isolated program a long string of memory which start with address 0. all the segment of that program will be addressed from its linear address.线性地址:对于一个孤立的程序来说,一长串 memory 从地址 0 开始。该程序的所有段都将从其线性地址寻址。 It may be in the ram or in the disk.它可能在内存中或磁盘中。

physical address : Address that appear in the ram or main memory pins.物理地址:出现在 ram 或主 memory 引脚中的地址。

logical address : Combination of swap memory in the disk and ram.逻辑地址:磁盘和内存中交换 memory 的组合。 All the linear memory for all the program will stay in logical address space.It can be only used by kernel mode.所有程序的所有线性 memory 都将停留在逻辑地址空间。它只能在 kernel 模式下使用。 The translation from logical to physical address is done by internal hardware.从逻辑地址到物理地址的转换由内部硬件完成。

virtual address : Virtual address is same as linear address.虚拟地址:虚拟地址与线性地址相同。 It will be only used by user mode in the operating system.它将仅由操作系统中的用户模式使用。 Operating system will map virtual address from logical address.操作系统将 map 虚拟地址取自逻辑地址。

The linear address space denotes all addresses that can be formed on the system.线性地址空间表示可以在系统上形成的所有地址。 An address for any byte in linear address space is called a linear address .线性地址空间中任何字节的地址称为线性地址 Todays system have around 46 bits of memory bus width, which corresponds to a linear address space of around 64 TiB.今天的系统有大约 46 位的 memory 总线宽度,对应于大约 64 TiB 的线性地址空间。 Intel only uses this term in its flat memory model. Intel 仅在其平面 memory model 中使用该术语。

The memory that the processor addresses on its bus is called physical memory.处理器在其总线上寻址的 memory 称为物理 memory。 Each byte is assigned a unique address, called a physical address .每个字节都分配有一个唯一的地址,称为物理地址 It should be noted that in addition to the memory, memory-mapped I/O devices are also connected to this bus and can be addressed.需要注意的是,除了 memory 之外,内存映射 I/O 设备也连接到该总线并且可以寻址。 This memory area also does not have to be contiguous, the memory controller here assigns the physical addresses to individual memory bars and devices. This memory area also does not have to be contiguous, the memory controller here assigns the physical addresses to individual memory bars and devices.

Paging now adds virtual address spaces: each program is assigned its own linear address space.分页现在增加了虚拟地址空间:每个程序都被分配了自己的线性地址空间。 Some addresses in this address space are valid, others are not.此地址空间中的一些地址是有效的,而另一些则不是。 valid addresses refer to data that may be in the physical memory but also to outsourced data on a hard disk (swap files).有效地址是指可能在物理 memory 中的数据,但也指硬盘上的外包数据(交换文件)。 The translation is done in hardware by the MMU (Memory Management Unit) together with the TLB (Translation Lookup Buffer) or by the operating system.翻译由 MMU(内存管理单元)和 TLB(翻译查找缓冲区)或操作系统在硬件中完成。 It is also possible that this data does not exist at all and is only generated when accessed, but this leads too far here.也有可能这些数据根本不存在,只有在访问时才生成,但这在这里太过分了。 Let us note that these are the virtual addresses .让我们注意这些是虚拟地址

Logical addresses are a term that intel uses in the segmented memory model: there the memory is divided into segments.逻辑地址是 intel 在分段 memory model 中使用的术语:memory 被划分为分段。 To address a byte in a segment, a logical address is used.为了寻址段中的字节,使用逻辑地址。 This consists of a segment selector and an offset.这由一个段选择器和一个偏移量组成。 Logical addresses are converted into virtual addresses using the segment selectors: The selector contains the beginning of the segment and its size.使用段选择器将逻辑地址转换为虚拟地址:选择器包含段的开头及其大小。 If the offset is larger than the size of the segment, the address is invalid.如果偏移量大于段的大小,则地址无效。 Adding the beginning of the segment to the offset gives you the virtual address.将段的开头添加到偏移量会为您提供虚拟地址。 This segmented memory model was largely abolished in 64bit mode.这个分段的 memory model 在 64 位模式下基本上被废除了。

Summary概括

Logical Addresses -> Virtual Addresses -> Physikal Addresses

Virtual addresses and physical addresses are linear addresses, but not the other way around.虚拟地址和物理地址是线性地址,反之则不然。


References:参考:

Isn't that to every process is given by OS a virtual address space 4GB or something.操作系统不是给每个进程一个虚拟地址空间 4GB 什么的。 Than this addresses are translated by compilers to logical addresses which is a CPU terminology independent of any OS implementation.然后,编译器将这些地址转换为逻辑地址,这是一个独立于任何操作系统实现的 CPU 术语。 So I think the correct sequence is:所以我认为正确的顺序是:

Virtual -> Logical -> Linear -> Physical

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM