Why is it so that 32 bit is limited to 4 GB RAM but it can easily support 1 TB HDDs?

How does the binary math work?


The problem is with addressing: the RAM addressing is done on per-byte basis, so 2^32 allows to make 4G bytes addressable.

The hard-drive addressing is done on per-sector basis. Each sector is 512 bytes long. Thus a single 32 bit value allows to address a sector in 2 TB disk.

To allow access for disks greater than 2TB the Operating System uses 64 bit sector addresses.

  • The Pentium Pro (IA-32) can address 64GB
    – wnrph
    Oct 12 '12 at 23:13
  • 1
    In 1985, 80386 processors could address more memory than the SCSI bus could address disk storage.
    – wnrph
    Oct 12 '12 at 23:16
  • 1
    @artistoex The IA-32 architecture virtually allow to address 16TB of RAM. But no one is trying to combine segment addressing with VMM. The question is about a bit different thing.
    – Serge
    Oct 12 '12 at 23:23
  • you mean memory requests for 16TB can be sent out on the address bus?
    – wnrph
    Oct 13 '12 at 9:00
  • @artistoex I mean that the program may simultaneously access 16TB of virtual addresses (with specific OS support of course)
    – Serge
    Oct 13 '12 at 12:24

It has nothing to do with binary mathematics. It's to do with the size of the address space you can create with a limited number of bits. Bits are exponential in terms of their individual addressing capabilities. Jumping from 32 bits to 64 bits does not grant you double the amount of address space than before, it grants you much much more. For example:

128 64 32 16 8 4 2 1

This is what 8 bits, or a byte looks like. Each bit is ordered and is of the value indicated. So with 8 bits, you can create a number in the range of 0 and 255. Try it yourself, add all the bits together and see what you get...

1 + 2 + 4 + 8 ... and so on = 255

Simply put as...

2^8 where 8 is the number of bits

However, add just one extra bit and you can step your value up to 511: (255 + 256) = 511

256 128 64 32 16 8 4 2 1

So imagine each address space is just a number, thus With 8 bits, you can address 256 bytes of memory. Perhaps the value 65536 or 64k looks familiar? That's because it is the number of bytes of memory that can be addressed with 16 bits. So with 32 bits, you can address 4 GB of memory:

2^32 = 4294967296 or 4GB

Now to answer your question about hard drives. Hard drives don't have static physical wires that require an address space. Hard drives are dynamic, in that they have moving parts. At any given time, the OS doesn't have to address each byte on a hard drive. It can address some of it in memory while it is required (hence reading from disk to memory), then written back when it's not required. The hard drive controller has a driver that allows the OS to interface with the file system. File systems have an index, that is addressable and uses that to either load extended indexes or know where to seek to on the disk in order to obtain the data. This is why hard drives are slow compared to memory, because data access is a very mechanical process.

Think of your hard drive as a book. You could start reading each page to find what you are looking for, but that could take weeks. Instead, you will look at the index at the back of the book to get the page numbers that contain relevant information. You will then seek to those pages and read the information into your short term memory, where you will process the facts. At some point you will need to memorise something else, at which point you forget about the minor details for what you just read. Next time you want to access that information again, you flick to the index, look up the page number again and seek to the page in the book, where you read it into short term memory again.

Hope this helps.

Not the answer you're looking for? Browse other questions tagged or ask your own question.