Reputation: 11
I have seen some explanations for my question online however, i still don't feel like i understand the problem at hand.
I understand that a 32 bit CPU will have its memory divided up into discrete units called words, which can each store up to 32 bits worth of data. The total number of memory locations which a 32 bit CPU can address is 2^32 or 4294967295 addresses. Now, since each address can hold up to 32 bits worth of data the total capacity of memory which can be utilised by this processor in bits should be 2^32 x 32 right? However, this value does not come out to 4 GB which is where my confusion lies. I would like to understand how this value of 4 GB is calculated.
Upvotes: 1
Views: 861
Reputation: 11537
You made 2 mistakes in your estimation:
1/ Addressing is (almost) always at the byte level. Otherwise most C programs would be broken. This makes the amount of memory independant of the size of the internal registers of the processors.
2/ Memory size is given in BYTEs not in BITs. So with a 32 bits physical address, you can have 2^32 Bytes of memory, ie 4GB.
Note that the size of the physical memory is partly uncorrelated with the processor register size. For year, there has some system hacks on the page table to go beyond the 4GB barrier. See for instance https://en.wikipedia.org/wiki/Physical_Address_Extension The real limit was on the virtual addresses that were limited to 32 bits (hence 4GB/process)
Now processors have 64 bits registers. Virtual adresses are 64 bits (more or less). But 2^64 is an insane amount of memory and to reduce costs physical addresses are generally limited to 40 or 48 bits. This is 256TB and is largely sufficient for current computers (and processors in the near future).
So the values 32 or 64 correspond to the virtual address size.
Upvotes: 2