gpt4 book ai didi

汇编段模型 32 位内存限制

转载 作者:行者123 更新时间:2023-12-02 22:07:39 25 4
gpt4 key购买 nike

如果使用分段内存模型运行 32 位操作系统,它们仍然是 4GB 限制吗?

我正在阅读英特尔奔腾处理器系列开发人员手册,它指出使用分段内存模型可以映射高达64TB的内存。

"In a segmented model of memory organization, the logical address space consists of as many as 16,383 segments of up to 4 gigabytes each, or a total as large as 2^46 bytes (64 terabytes). The processor maps this 64 terabyte logical address space onto the physical address space by the address translation mechanism described in Chapter 11. Application programmers can ignore the details of this mapping. The advantage of the segmented model is that offsets within each address space are separately checked and access to each segment can be individually controlled.

alt text

这不是一个复杂的问题。我只是想确保我正确理解了文本。如果 Windows 或任何其他操作系统在分段模型而不是平面模型中工作,内存限制是否为 64TB?

<小时/>

更新:

alt text

英特尔的 3-2 3a 系统文档。

<小时/>

alt text

http://pdos.csail.mit.edu/6.828/2005/readings/i386/c05.htm

<小时/>

不应将段寄存器视为传统实模式意义上的段寄存器。段寄存器充当全局描述符表的选择器。

In Protected mode you use a logical address in the form A:B to address memory. As in Real Mode, A is the segment part and B is the offset within that segment. The registers in > protected mode are limited to 32 bits. 32 bits can represent any integer between 0 and 4Gb. Because B can be any value between 0 and 4Gb our segments now have a maximum size of 4Gb (Same reasoning as in real-mode). Now for the difference. In protected mode A is not an absolute value for the segment. In protected mode A is a selector. A selector represents an offset into a system table called the Global Descriptor Table (GDT). The GDT contains a list of descriptors. Each of these descriptors contains information that describes the characteristics of a segment.

段选择器提供了分页无法实现的额外安全性。

Both of these methods [Segmentation and Paging]have their advantages, but paging is much better. Segmentation is, although still usable, fast becoming obsolete as a method of memory protection and virtual memory. In fact, the x86-64 architecture requires a flat memory model (one segment with a base of 0 and a limit of 0xFFFFFFFF) for some of it's instructions to operate properly.

Segmentation is, however, totally in-built into the x86 architecture. It's impossible to get around it. So here we're going to show you how to set up your own Global Descriptor Table - a list of segment descriptors.

As mentioned before, we're going to try and set up a flat memory model. The segment's window should start at 0x00000000 and extend to 0xFFFFFFFF (the end of memory). However, there is one thing that segmentation can do that paging can't, and that's set the ring level.

-http://www.jamesmolloy.co.uk/tutorial_html/4.-The%20GDT%20and%20IDT.html

例如,GDT 列出了各个用户的访问级别和内存访问区域:

GDT 表示例

GDT[0] = {.base=0, .limit=0, .type=0};             
// Selector 0x00 cannot be used
GDT[1] = {.base=0, .limit=0xffffffff, .type=0x9A};
// Selector 0x08 will be our code
GDT[2] = {.base=0, .limit=0xffffffff, .type=0x92};
// Selector 0x10 will be our data
GDT[3] = {.base=&myTss, .limit=sizeof(myTss), .type=0x89};
// You can use LTR(0x18)

http://wiki.osdev.org/GDT_Tutorial#What_should_i_put_in_my_GDT.3F

分页部分映射到物理内存。 (PAE) 可提供高达 64GB 的额外内存。

简而言之。答案是否定的,您不能拥有超过 4GB 的逻辑内存。我认为《英特尔奔腾处理器系列开发人员手册》中关于 64TB 的说法是打印错误。

最佳答案

编辑:我的回答假设“4GB 限制”指的是线性(虚拟)地址空间的最大大小,而不是物理地址空间的最大大小。正如下面的评论中所解释的,后者实际上根本不限于 4GB - 即使使用平面内存模型也是如此。

<小时/>

重复您的引用,并强调:

the logical address space consists of as many as 16,383 segments of up to 4 gigabytes each

现在,引用《英特尔® 64 和 IA-32 架构软件开发人员手册第 1 卷:基本架构》(PDF 可用 here):

Internally, all the segments that are defined for a system are mapped into the processor’s linear address space.

正是这个线性地址空间(在32位处理器上)被限制为4GB。因此,分段内存模型仍然会受到限制。

关于汇编段模型 32 位内存限制,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4039325/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com