简体   繁体   English

整个物理地址空间如何映射到虚拟地址空间中?

[英]How does entire physical address space is mapped in virtual address space?

I have read that in XV6, in every process virtual address space entire physical address space is mapped.我在 XV6 中读到过,在每个进程的虚拟地址空间中,整个物理地址空间都被映射。 How is that even possible?这怎么可能呢?

I have read that in XV6, in every process virtual address space entire physical address space is mapped.我在 XV6 中读到过,在每个进程的虚拟地址空间中,整个物理地址空间都被映射。 How is that even possible?这怎么可能呢?

Typically virtual address spaces are split into 2 areas - user-space (belonging to the current process) and kernel-space (same for all processes).通常,虚拟地址空间分为 2 个区域 - 用户空间(属于当前进程)和内核空间(所有进程都相同)。 Kernel-space is then split into smaller areas (kernel's code & data, areas for memory mapped devices, etc).然后将内核空间分成更小的区域(内核的代码和数据、memory 映射设备的区域等)。 If the remaining amount of kernel space is large enough to hold the entire physical address space, then there's no problem (but this is extremely unlikely).如果 kernel 空间的剩余量大到足以容纳整个物理地址空间,那么就没有问题(但这极不可能)。

However;然而; this probably isn't what XV6 actually does.这可能不是 XV6 实际所做的。 Far more likely is that it only maps physical RAM into kernel space (and does not map the entire physical address space at all).更有可能的是,它只将物理 RAM 映射到 kernel 空间(而不是 map 整个物理地址空间)。

For some real numbers;对于一些实数; assume you have a computer with 128 MiB of RAM and a 32-bit CPU with 4 GiB of physical address space (where most of the physical address space is unused and isn't RAM);假设您有一台具有 128 MiB RAM 的计算机和一个具有 4 GiB 物理地址空间的 32 位 CPU(其中大部分物理地址空间未使用且不是 RAM); and you also have 256 MiB of kernel space left over.您还剩下 256 MiB 的 kernel 空间。 In that case, 128 MiB of RAM would fit in the remaining 256 MiB of kernel space (but the whole 4 GiB of the physical address space will not).在这种情况下,128 MiB 的 RAM 将适合剩余的 256 MiB kernel 空间(但整个 4 GiB 的物理地址空间不适合)。

Of course this is still likely to fail on real systems (whenever there's too much RAM, and especially for 32-bit CPUs).当然,这在实际系统上仍然可能会失败(只要 RAM 太多,尤其是对于 32 位 CPU)。 Fortunately XV6 is only for "educational purposes" and isn't expected to actually work on real computers, so that's not a major problem.幸运的是,XV6 仅用于“教育目的”,预计不会在真实计算机上实际运行,所以这不是一个大问题。

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

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