为什么分页让我们使用的物理内存大于 CPU 的地址指针长度所能寻址的内存?
Why does paging let us use physical memory that is larger than what can be addressed by the CPU's address pointer length?
我正在阅读 Avi Silberschatz 的操作系统概念,在第 8 章 Main Memroy 中,它是这样的:
Frequently, on a 32-bit CPU, each page-table entry is 4 bytes long, but that
size can vary as well. A 32-bit entry can point to one of 232 physical page frames.
If frame size is 4 KB (212), then a system with 4-byte entries can address 244 bytes
(or 16 TB) of physical memory. We should note here that the size of physical
memory in a paged memory system is different from the maximum logical size
of a process. As we further explore paging, we introduce other information that
must be kept in the page-table entries. That information reduces the number of bits available to address page frames.A 32-bit
CPU uses 32-bit addresses, meaning that a given process space can only be 232
bytes (4 GB). Therefore, paging lets us use physical memory that is larger than
what can be addressed by the CPU’s address pointer length.
我现在对一些概念真的很困惑。
在第一个例子中(4KB帧大小和232帧),由于我们有32位帧号和12位偏移量,所以逻辑地址是44位?那么逻辑地址space和CPU的字长有什么关系呢?
第二个例子(32位CPU使用32位地址),CPU的地址指针长度可以寻址的物理内存应该怎么理解?由于 CPU 使用 32 位地址,CPU 的地址指针是否为 32 位长?
In the first example(4KB frame size and 232 frames), since we have
32-bit frame number and 12-bit offset, is the logical address 44-bit?
从纯粹的理论角度来看,这是可能的,但实际上页面 table 条目还包含诸如脏位、设置位和许多其他用于虚拟内存管理目的的信息。
你的书在这里讲到
As we further explore paging, we introduce other information that must be kept in the page-table entries
。 That information reduces the number of bits available to address page frames.
所以即使页面 table 条目大小是 32 位,我们也不能将所有位都用于帧号。
通常在 32 位 CPU 中,每个进程都有一个逻辑地址 space 等于 4 GiB,如果我们的帧大小等于 4096 字节,那么实际上我们需要 20 位的页码。剩余的12位可用于存储其他相关信息。
In the second example(32-bit CPU using 32-bit addresses), how should I
understand the physical memory that can be addressed by the CPU's
address pointer length?
这只是上述事实的延伸。例如,如果您决定使用 21 位而不是 20 位作为帧号,那么您的逻辑地址 space 将翻倍为 8 Gib。但是,您必须使用某种机制将这个 8 GiB 逻辑地址 space 映射到 4 GiB(可能会将一些页面换出到磁盘)物理地址 space 因为通常(不使用一些花哨的技术)32 位CPU 将限制为 4 GiB 的物理内存。
是
总结:-物理地址space由CPU的程序计数器决定。一个 32 位 CPU 将有一个 32 位程序计数器。逻辑地址 space 只是为了安全和多编程以及其他目的而添加的抽象。无论你的逻辑地址space有多大,最终它都必须映射到物理地址space。
观看这些视频以获得进一步的解释。
Virtual Memory playlist
我正在阅读 Avi Silberschatz 的操作系统概念,在第 8 章 Main Memroy 中,它是这样的:
Frequently, on a 32-bit CPU, each page-table entry is 4 bytes long, but that size can vary as well. A 32-bit entry can point to one of 232 physical page frames. If frame size is 4 KB (212), then a system with 4-byte entries can address 244 bytes (or 16 TB) of physical memory. We should note here that the size of physical memory in a paged memory system is different from the maximum logical size of a process. As we further explore paging, we introduce other information that must be kept in the page-table entries. That information reduces the number of bits available to address page frames.A 32-bit CPU uses 32-bit addresses, meaning that a given process space can only be 232 bytes (4 GB). Therefore, paging lets us use physical memory that is larger than what can be addressed by the CPU’s address pointer length.
我现在对一些概念真的很困惑。
在第一个例子中(4KB帧大小和232帧),由于我们有32位帧号和12位偏移量,所以逻辑地址是44位?那么逻辑地址space和CPU的字长有什么关系呢?
第二个例子(32位CPU使用32位地址),CPU的地址指针长度可以寻址的物理内存应该怎么理解?由于 CPU 使用 32 位地址,CPU 的地址指针是否为 32 位长?
In the first example(4KB frame size and 232 frames), since we have 32-bit frame number and 12-bit offset, is the logical address 44-bit?
从纯粹的理论角度来看,这是可能的,但实际上页面 table 条目还包含诸如脏位、设置位和许多其他用于虚拟内存管理目的的信息。
你的书在这里讲到
As we further explore paging, we introduce other information that must be kept in the page-table entries
。 That information reduces the number of bits available to address page frames.
所以即使页面 table 条目大小是 32 位,我们也不能将所有位都用于帧号。 通常在 32 位 CPU 中,每个进程都有一个逻辑地址 space 等于 4 GiB,如果我们的帧大小等于 4096 字节,那么实际上我们需要 20 位的页码。剩余的12位可用于存储其他相关信息。
In the second example(32-bit CPU using 32-bit addresses), how should I understand the physical memory that can be addressed by the CPU's address pointer length?
这只是上述事实的延伸。例如,如果您决定使用 21 位而不是 20 位作为帧号,那么您的逻辑地址 space 将翻倍为 8 Gib。但是,您必须使用某种机制将这个 8 GiB 逻辑地址 space 映射到 4 GiB(可能会将一些页面换出到磁盘)物理地址 space 因为通常(不使用一些花哨的技术)32 位CPU 将限制为 4 GiB 的物理内存。
是
总结:-物理地址space由CPU的程序计数器决定。一个 32 位 CPU 将有一个 32 位程序计数器。逻辑地址 space 只是为了安全和多编程以及其他目的而添加的抽象。无论你的逻辑地址space有多大,最终它都必须映射到物理地址space。
观看这些视频以获得进一步的解释。 Virtual Memory playlist