0

(Preamble: I understand that there are similar questions, but I'm specifically trying to understand why having more than 32 bits help accessing that 0.5 GB when having 232 addresses is more than enough to access the 3.5 GB of the RAM.)

I'm learning about OSes and read that running a 64-bit OS on a 4GB RAM allows the user to take full advantage of the 4GB, while this is not possible with a 32-bit OS (If I understand correctly, the reason for this is because the 4GB is shared with other hardware components, one of which I know is the GPU.).

Could anyone please help explain to me how this is possible? If a 32-bit OS cannot use all 232 address locations (i.e. 4GB), how does increasing the number of bits the OS can work with at a time to 64 bits solve the problem?

phuclv
  • 26,555
  • 15
  • 113
  • 235
Dxml
  • 103
  • 5
  • Arguably [this](https://superuser.com/questions/367490/can-a-32-bit-os-machine-use-up-all-8gb-ram-20gb-page-file?rq=1) might be a better duplicate – Ramhound Oct 09 '21 at 03:57
  • Thanks, @Ramhound. I actually saw those two questions, but the focus of my question is different. With the fact that a 32-bit OS can only address .32-3.5GB of the RAM, how does having the extra 32 bits (i.e. 32 + 32, i.e. using the 64-bit OS) help accessing the remaining 0.5 - 0.8 GB of the RAM. Thanks! – Dxml Oct 09 '21 at 05:00
  • 1
    How does the answer to [this](https://superuser.com/questions/212178/why-32bits-oss-cant-address-more-than-3-2-3-2-gb-of-memory?noredirect=1&lq=1) question not answer your question? Both questions are asking something. The limitation of a 32-bit OS is due to the processor not necessarily the OS. – Ramhound Oct 09 '21 at 13:55
  • @Ramhound The question you referenced is not the same as my question. My logic is that, if I keep my RAM unchanged at 4GB, regardless of whether my OS is 32-bit or 64-bit, the 0.5 GB has to be shared wither other resources anyway. So how is it that a 32-bit OS cannot use that 0.5 GB, while a 64-bit OS can? I'm trying to pinpoint the flaw in my logic. And logic doesn't seem to change whether we're comparing 32- vs 64-bit OS or 32- vs 64-bit processors; the 4GB RAM (and more specifically the 0.5 GB that is used by other resources) is still the bottleneck. What do I get wrong here? Thanks! – Dxml Oct 09 '21 at 18:47

2 Answers2

3

In other words, if 32-bit OS can only use 3.5 GB

A 32-bit OS can address 4GB of address space, however in that address space there are not only RAM but various shadowed memories and memory-mapped devices. In x86 port-mapped IOs are more common but still there are lots of memory-mapped things out there

For example some of that may be reserved for the COM and LPT ports, and some remaining would be kept for the network interfaces and graphics card. If you have a 1GB GPU on your system then the OS has only maximum 3GB of address space for its RAM. That's not even 3.5GB

On most RISC architectures memory-mapped IOs are more commonly used so 32-bit RISC OSes may address even fewer RAM


However that's not the entire story because many 32-bit architectures use more than 32 bits for the address, so a 32-bit OS running on those isn't necessarily limited to 4GB of RAM. For example in x86 there's PAE which allows OSes to use at least 36 bits for the address, which means they can address 64GB of RAM or more. The equivalent in ARM is LPAE

But only the OS can use such a huge amount of RAM. A 32-bit process running on that OS still uses 32-bit addresses, so can still address only 232 different memory locations, which are bytes in most modern architectures, so in theory they can access at most 4GB of RAM

In practice only a part of that belongs to the process, because the kernel reserves the remaining address space for themselves. On Windows the default split is 2GB/2GB (before Meltdown). That's why Adobe Premiere CS4 (which is still a 32-bit only version) spawns a process for each 2GB of RAM in the system in order to utilize all the available RAM in the OS

how does having an extra 32 bits help accessing the remaining 0.5 GB

The extra 32 bits help accessing a new space 232 times larger than the 4GB address space, so obviously it overcomes almost all the imaginable limits. 0.5GB is nothing in that space

Would upgrading my OS from 32-bit to 64-bit, while keeping my RAM unchanged at 4GB, help access remaining 0.5 GB that the 32-bit OS cannot access? If yes, how? Isn't that 0.5 GB still have to be shared with other resources, regardless of whether the OS can access 2^23 or 2^64 address space?

Why not? If you have a larger space then there's obviously more space to map that 0.5GB into. If you have so much space available then some devices can be mapped above 4GB. In the memory-map mechanism each device will be mapped into a range in the available address space. It doesn't mean that the RAM space is shrunk if another device is using the address space. The 32-bit OS can't use that not because the address space is smaller, but because some address range is mapped to another device instead of RAM

For example if we have 4GB of address space then RAM might be mapped into the range 0-2GB and a GPU with 1GB VRAM will be mapped into the top 1GB (i.e. address 0xC0000000). But if we have 4294967296GB of address space then that GPU can be mapped into the address at 12345678GB instead, leaving the low 4GB range for RAM and now you can use the whole 4GB memory available (roughly, because there are always small pages of memory that's not available due to shadowing and other things)

Don't you see modern GPUs having 8GBs of VRAM or more? And there can even be multiple GPUs and NICs in a system. Sometimes mapping errors can happen, for example a PCIe device is mapped into the position at 2GB and limits the available RAM. In that case some tuning is necessary to change the mapping to maximize the available RAM. See

phuclv
  • 26,555
  • 15
  • 113
  • 235
  • 1
    @Dxml obviously. There's no "sharing" of address space here, you seem to misunderstood the memory-map mechanism. Please see my update. Note that x86-64 has been around for 18 years, so there's no reason to keep using a 32-bit OS nowadays, giving the [lack of security updates](https://superuser.com/a/1357145/241386) and the inferior performance – phuclv Oct 10 '21 at 01:42
  • Ah! Thank you! I finally get the answer I was looking for. So the problem was that I misunderstood that the shared resource was the RAM, when it was actually the OS that was the limiting factor. Really appreciate your patience! – Dxml Oct 10 '21 at 17:39
  • 1
    @Dxml the OS has nothing to do with this. Address mapping isn't done by it but mostly by the UEFI/BIOS and the hardware controllers under the hood – phuclv Oct 11 '21 at 01:11
  • I have a follow-up question from your response yesterday, if you don't mind. Let's assume I have a 32-bit processor, a 4GB RAM, and a 32-bit OS. Am I able to use all 4GB of the RAM? If not, would upgrading the OS to 64-bit make any difference? Thanks! – Dxml Oct 12 '21 at 19:16
  • Sorry, in my first question above, I meant to say 64-bit processor, 32-bit OS and 4GB RAM. – Dxml Oct 12 '21 at 21:41
  • 1
    @Dxml I already answered that above, please read again. With PAE in x86 you have an address space of more than 4GB so theoretically the answer is yes. But in case of non-server versions of Windows there's a software limit of 4GB due to licensing reasons. You can only use more than 4GB RAM in 32-bit Windows Server or other 32-bit OSes like Linux – phuclv Oct 18 '21 at 09:45
  • 1
    In the past there were some patches to remove that restriction but it's a bad idea to use, just install a 64-bit OS instead. [Is there way to enable more than 4 GB RAM in 32-bit Windows OS?](https://superuser.com/a/95311/241386), [How can I enable PAE on Windows 7 (32-bit) to support more than 3.5 GB of RAM?](https://superuser.com/a/95309/241386) – phuclv Oct 18 '21 at 09:52
2

Why can a 32-bit OS use just 3.5 GB?

From my understanding the main reason for the limitation is the difference in the CPU register between 32-bit and 64-bit

Why is 32-bit limited to under 4 GB

The CPU register stores memory addresses, which is how the processor accesses data from RAM. One bit in the register can reference an individual byte in memory, so a 32-bit system can address a maximum of 4 gigabytes (4,294,967,296 bytes) of RAM. The actual limit is often less – around 3.5 gigabytes – since part of the registry is used to store other temporary values besides memory addresses.

But whatever the very exact reason, the limit above is not enough for modern operating systems, so 64-bit systems are used.

A 64-bit OS can address 18,446,744,073,709,551,616 bytes, (or about 18.4 exabytes) of memory.

John
  • 46,167
  • 4
  • 33
  • 54
  • @John x86-64 has been available since 2003 and OSes started [supporting it in 2004](https://en.wikipedia.org/wiki/X86-64#Operating_system_compatibility_and_characteristics) with the first x86-64 Windows in 2005, not 2008. In non-server Windows versions even with PAE you can't use more than 4GB because of a software licensing limit, similar to how some 64-bit Windows can only use 128GB of RAM – phuclv Oct 10 '21 at 01:45