为什么 32 位操作系统支持 4 GB RAM?

发布于 2024-07-27 00:32:31 字数 240 浏览 3 评论 0原文

只是阅读普渡大学关于操作系统的讲座中的一些笔记,它说:

程序将内存视为数组 从地址 0 到 2^32-1 的字节(0 到 4GB-1)

为什么是 4 GB?

Just reading some notes in a purdue lecture about OSs, and it says:

A program sees memory as an array of
bytes that goes from address 0 to 2^32-1 (0 to
4GB-1)

Why 4 GB?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(13

慕巷 2024-08-03 00:32:31

由于 32 位能够表示最多 232 − 1 = 4294967295 = 4 GiB − 1 的数字,因此最多可寻址 232 个字节,即 4 GiB 。

不过,有一些方法可以避免这种情况。 例如,使用 PAE 即使 32 位操作系统也可以支持更多内存。 不过,从历史上看,这最常用于服务器。 此外,非服务器 Windows SKU 也不支持它。 不过,到目前为止,鉴于 64 位 CPU、操作系统和驱动程序支持已经很普遍,所有这些都没有实际意义。

Because 32 bits are able to represent numbers up to 232 − 1 = 4294967295 = 4 GiB − 1 and therefore address up to 232 individual bytes which would be 4 GiB then.

There are ways to circumvent that, though. For example using PAE even a 32-bit operating system can support more memory. Historically this has most commonly been used on servers, though. Also, the non-server Windows SKUs don't support it. By now all that is moot, though, given that 64-bit CPUs, OSes and driver support are commonplace.

断念 2024-08-03 00:32:31

因为内存的每个字节都必须有一个地址。 在32位操作系统中,地址的长度是32位; 因此,有 2^32 个可能的地址,这意味着有 2^32 字节 = 4 GB。

Because each byte of memory has to have an address. In a 32-bit operating system, an address is 32 bits long; thus, there are 2^32 possible addresses, which means there are 2^32 bytes = 4 GB.

东京女 2024-08-03 00:32:31

如果您使用的是 4 位系统,这意味着每个字节的地址是 4 个二进制数字,所有地址的概率范围为 000011112^4 = 16(2 因为有 0 或 1),用四位可以创建 16 不同的 0 和 1 值,如果你有16个不同的地址。 每个代表一个字节,那么您最多可以有16字节

4位系统将如下所示:

在此处输入图像描述

对于 32 位系统,最大值为 2^32 = 4294967292 字节

If you have a 4-bit system, this means the address for each byte is 4 binary digits, the probability of all your address will range from 0000 through 1111 which is 2^4 = 16 (2 because there is either 0 or 1), with four bits it's possible to create 16 different values of zeros and ones, If you have 16 different addr. each represent a byte then you can have a max of 16 bytes

4-bit system will look like this:

enter image description here

For a 32-bit system, your max is 2^32 = 4294967292 bytes

执手闯天涯 2024-08-03 00:32:31

大家都说 2^32 = 4GiB,这是正确的。 为了以防万一,我们是这样实现的:

32 位机器使用 32 位来寻址内存。 每个位的值为 0 或 1。如果有 1 位,则有两个可能的地址:0 或 1。
两位系统(双关语除外)有四种可能的地址:00 = 0、01 = 1、10 = 2、11 = 3。 2^2=4。
三位有 8 个可能的地址:000=0、001=1、010=2、011=3、100=4、101=5、110=6 和 111=7。

每个位都会使潜在的地址空间加倍,这就是为什么 2^n 告诉您对于给定的位数使用了多少个地址。 2^1 = 2、2^2 = 2*2 = 4、2^3 = 2*2*2 = 8 等。

当您达到 32 位时,您的大小为 4GiB。

Everybody is saying 2^32 = 4GiB, which is right. Just in case, here is how we got there:

A 32-bit machine uses 32 bits to address memory. Each bit has a value of 0 or 1. If you have 1 bit, you have two possible addresses: 0 or 1.
A two-bit system ( pun aside ) has four possible address: 00 =0, 01=1, 10=2, 11=3. 2^2=4.
Three bits have 8 possble addresses: 000=0, 001=1, 010=2, 011=3, 100=4, 101=5, 110=6, and 111=7.

Each bit doubles the potential address space, which is why 2^n tells you how many addresses you use for a given number of bits. 2^1 = 2, 2^2 = 2*2 = 4, 2^3 = 2*2*2 = 8, etc.

By the time you get to 32 bits, you are at 4GiB.

情痴 2024-08-03 00:32:31

4 GB = 2^32 字节。

4 GB = 2^32 bytes.

耳根太软 2024-08-03 00:32:31
2 ^ 32 = 4 * 1024 * 1024 * 1024

这就是 4 GB 的定义(以字节为单位)。 换句话说,32 位寄存器作为内存指针只能寻址 4 GB 内存,仅此而已。

2 ^ 32 = 4 * 1024 * 1024 * 1024

That, in bytes, is the definition of 4 GB. In other words a 32-bit register as a memory pointer can address 4 GB of memory and no more.

酒解孤独 2024-08-03 00:32:31

实际上,它并不像 2^32 = 4294967296 字节那么简单。 您会看到,在 x86 保护模式下,启用分页(即使用任何现代操作系统时所得到的)时,您不会直接寻址内存位置,即使分页转换机制对于客户端应用程序是透明的。

对于逻辑 32 位内存地址,使用 4K 页时:

  • 位 22-31 指页目录
  • 位 12-21 指页表
  • 位 11-0 指 4096 字节页中的偏移量

如您所见,您有 2^10 (1024) 个页目录,在每个页目录中,有 2^10 个页表,每个页长 2^12 (4096) 个字节,因此 2^32 = 4294967296 个字节。 内存总线的宽度通常与 CPU 的字长相同,但完全没有必要如此。 事实上,更现代的 x86 CPU 支持 PAE,即使在 32 位模式下也能寻址超过 4GB(或 GiB)。

Actually, it's not as simple as 2^32 = 4294967296 bytes. You see in x86 protected mode, with paging enabled (that is, what you get when you use any modern OS), you don't address memory locations directly, even though the paging translation mechanism is transparent for client applications.

Of a logical 32 bit memory address, when using 4K pages:

  • bits 22-31 refer to a page directory
  • bits 12-21 refer to a page table
  • bits 11-0 refer to an offset in the 4096 byte page

As you can see, you have 2^10 (1024) page directories, in each page directory, you have 2^10 page tables and each page is 2^12 (4096) bytes long, hence 2^32 = 4294967296 bytes. The width of the memory bus is conveniently the same as the word length of the CPU but it's not necessary to be like this at all. In fact, more modern x86 CPUs support PAE which enables addressing more than 4GB (or GiB) even in 32-bit mode.

找回味觉 2024-08-03 00:32:31
  1. 32bit可以表示数字 0..2^32 = 0..4,294,967,296
  2. 32bit可以寻址最多 2^32Bytes(假设字节大小块)
  3. 2^32Bytes 是最大大小

2^32B = 4,194,304 KiB = 4,194MiB = 4GiB

  1. 32bits can represent numbers 0..2^32 = 0..4,294,967,296
  2. 32bits can address up to 2^32Bytes (assuming Byte-size blocks)
  3. 2^32Bytes is the max size

2^32B = 4,194,304KiB = 4,194MiB = 4GiB

后eg是否自 2024-08-03 00:32:31

因为 是一个字中可以存储的不同内存地址的数量(以字节为单位)。

但事实上,这并不总是正确的(在大多数情况下并非如此),操作系统可以处理比这更多的物理内存(使用 PAE),并且应用程序可以使用少于 4GB 的虚拟内存(因为该虚拟内存的一部分)。内存映射到操作系统,例如,Linux 中为 1GB,Windows 中为 2GB)。

另一种不适用的情况是,如果内存是按字而不是字节寻址的,那么可寻址的总内存将为 16GB。

Because is the amount of different memory addresses (in Bytes) that can be stored in a Word.

But, in fact, that's not always true (in most of cases it isn't), the OS can handle more physical memory than that (with PAE) and the applications can use less than 4GB of virtual memory (because part of that virtual memory is mapped to the OS, 1GB in Linux and 2GB in Windows, for example).

Another scenario where that doesn't apply is if the memory was addressed by Words instead of Bytes, then the total memory addressable would be 16GB, for example.

笔芯 2024-08-03 00:32:31

具有 32 位寄存器的 CPU 需要操作系统以 32 位块的形式计算所有内容。 这是操作系统必须遵守的硬件要求。 同样,具有 64 位寄存器的 CPU 需要一个能够以 64 位块的形式从 RAM 读取和写入数据的操作系统。 (每次从内存中读取数据时,都需要将其读入这些寄存器之一 - 无论是 32 位、64 位还是 16 位等)

32 位寄存器可以存储 2^32 个不同的 RAM 地址。
每个 RAM 地址对应现代 RAM 中的一个字节(8 位)。 (4 GB 参数仅适用于每个字节都有地址的 RAM。

) 2^32 = 4,294,967,296 个地址,→ 对应于 4,294,967,296 个字节。

现在,1 KB = 2^10 字节或 1024 字节(在二进制系统中)

因此,4,294,967,296 字节 / 1024 = 4,194,304 KB

4,194,304 KB / 1024 = 4,096 MB

4,096 MB / 1024 = 4 GB

A CPU with 32 bit registers will need the operating system to calculate everything in chunks of 32 bits. It's a hardware requirement to which the OS must conform. Similarly, CPUs with 64 bit registers will need an operating system that reads and writes data from the RAM in chunks of 64 bits. (Every time you read data from memory, you need to read it into one of those registers - be it 32 bit, or 64 bit, or 16 bit, etc.)

A 32 bit register can store 2^32 different RAM addresses.
Each RAM address corresponds to a byte (8 bits) in modern RAMs. (The 4 GB argument is true only for those RAMs that have addresses for every byte.)

=> 2^32 = 4,294,967,296‬ addresses, → that corresponds to 4,294,967,296‬ bytes.

Now, 1 KB = 2^10 bytes or 1024 bytes (in the binary system)

Therefore, 4,294,967,296‬ bytes / 1024 = 4,194,304‬ KB

4,194,304‬ KB / 1024 = 4,096‬ MB

4,096‬ MB / 1024 = 4 GB

一花一树开 2024-08-03 00:32:31

主要是由于 32 位操作系统选择仅支持 2^32-1 地址。

如果CPU在FSB上有超过32条地址线,那么32位操作系统可以选择使用分页机制来访问超过4GiB。 (例如,PAE 支持的 Intel/AMD 芯片上的 Windows 2000 Advanced Server/Data Center 版本)

Mainly due to 32bit OS chosing to support only 2^32-1 addresses.

If the CPU has more than 32 address lines on the FSB, then the 32bit OS can choose to use a paging mechanism to access more than 4GiB. (For example Windows 2000 Advanced Server/Data Center editions on PAE supported Intel/AMD chips)

顾北清歌寒 2024-08-03 00:32:31

4 GB = 2^32 字节。
但请记住 32 位操作系统分配的最大 4GB。 事实上,操作系统会看到更少,例如在分配 VRAM 后。

4 GB = 2^32 bytes.
But remember its max 4gb allocated by a 32 bit OS. In reality, the OS will see less e.g. after VRAM allocation.

满意归宿 2024-08-03 00:32:31

正如其他用户之前所说,32 位 Windows 操作系统使用 32 位字来存储内存地址。

实际上,现在大多数 32 位芯片都使用 36 位寻址,即使用英特尔的物理地址扩展 (PAE) 模型。 有些操作系统直接支持这一点(例如 Linux)。

正如 Raymond Chen 指出的,在 Windows 中 32 位应用程序可以分配超过 4GB 的内存,并且不需要 64 位 Windows 来执行此操作。 甚至PAE。

因此,64 位芯片不支持整个 64 位内存空间。 我相信它们目前仅限于 42 位空间...PAE 使用的 36 位空间,加上顶部 8 位地址,

As previously stated by other users, 32-bit Windows OSes use 32-bit words to store memory addresses.

Actually, most 32-bit chips these days use 36-bit addressing, using Intel's Physical Address Extension (PAE) model. Some operating systems support this directly (Linux, for example).

As Raymond Chen points out, in Windows a 32-bit application can allocate more than 4GB of memory, and you don't need 64-bit Windows to do it. Or even PAE.

For that matter, 64-bit chips don't support the entire 64-bit memory space. I believe they are currently limited to 42-bit space... the 36-bit space that PAE uses, plus the top 8-bit addresses,

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文