Why does a 32-bit OS support 4 GB of RAM?
Asked Answered
I

13

41

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?

Internal answered 13/7, 2009 at 12:55 Comment(3)
4 GB is the theoretical maximum of memory you can use with a 32-bit OS. Practically you cannot use the full 4GB memory (maybe only 3,5 GB) because you also need some adress-space for other hardware components like: CPU, HDD, grafic card, etc.Submerged
The question from the topic is wrong. 32-bit OS can support more RAM; it will just see 4GB at a time.Enforce
Technically, PAE can give you more than 4GiBPitchdark
F
65

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.

Figureground answered 13/7, 2009 at 12:57 Comment(5)
I think this gibibyte thing is just as pointless as arguing whether Pluto is a planet (it is, by the way)Giovannigip
GiB belongs on slashdot and wikipedia. The rest of the world uses GB (no matter what the committee says.)Formwork
When said rest of world aren't all using it the same way, that's hardly a good thing, GregGrindstone
Given that this is a forum giving answers to technical questions, I feel that the answers should be accurate. "Giga" is a SI prefix with a specific meaning. 4 Gigabytes is 4,000,000,000 bytes which is not equal to 2³².Hallett
@Life: 2³¹ + 1 is 2147483649.Figureground
R
35

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.

Rhodonite answered 13/7, 2009 at 12:58 Comment(4)
"Because each byte of memory has to have an address." - in a byte addressable system only, of course. In a word-addressable platform you could have twice the amount of memory...Cymbre
or more, depending on what size your machines words areBasin
Can you explain for me why 2^32 addresses mean 2^32 bytes? Thanks.Scripture
@hqt: In basic cases, each byte has an address, therefore number of addresses == number of bytes.Rhodonite
A
31

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

Alvie answered 26/10, 2016 at 18:5 Comment(0)
J
26

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.

Jarad answered 13/7, 2009 at 13:13 Comment(1)
Right! 2^32-1 is the sum of Geometric Sequences.Themistocles
S
13

4 GB = 2^32 bytes.

Sauder answered 13/7, 2009 at 12:57 Comment(0)
C
9
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.

Conny answered 13/7, 2009 at 12:57 Comment(0)
G
6

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.

Giovannigip answered 13/7, 2009 at 13:18 Comment(1)
PAE doesn't allow you to address more than 4GiB unless the you in question is running in supervisor mode and considers that rewriting the page table between accesses still constitutes "addressing" at which point you could nearly argue that you can "address" the data on disk too... PAE is a neat hack, but it's just a hack.Basin
S
3
  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

Scorekeeper answered 19/5, 2019 at 4:59 Comment(1)
Don't you mean 4,096MiB?Positively
H
2

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.

Hokusai answered 13/7, 2009 at 12:59 Comment(0)
B
2

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

Beamends answered 12/2, 2020 at 21:58 Comment(0)
F
1

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)

Ferruginous answered 13/7, 2009 at 13:33 Comment(0)
N
0

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.

Nikitanikki answered 13/7, 2009 at 13:0 Comment(0)
S
0

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,

Spelling answered 13/7, 2009 at 15:25 Comment(2)
Even if you can allocate more than 4GB of memory, you can't use more than 4GB of RAM without 64-bit or PAE.Neils
You can check out how many physical and virtual address bits actually work on your CPU with CPUID (on x86) or the analogous features on other families of processors. You can also see it in Linux's /proc/cpuinfo My cheap corner store PC has 40 bits of physical addresses and 48 bits of virtual. The old Xeons in our server rack have only 36 bits of physical addresses (no matter, they can only take 16GiB of DIMMs)Basin

© 2022 - 2024 — McMap. All rights reserved.