Question

I am just wondering that by saying 32-bit machine and 64-bit machine, what exactly is it that consists of 32(64) bits in the machine so that we define it as a 32(64)-bit machine. Since I'm currently learning C, I found the relationship between pointer and memory explains this quite much. Since one memory address points to one byte, so if the memory address consists of 32 bits (i.e. a pointer is of 4 bytes), it can have at most 2^32 possibilities, which means it can represent at most 2^32 bytes which causes a 32-bit machine supports at most 4GB RAM. Is that fair assumption? So is 32-bit or 64-bit machine defined by its memory address size?

Furthermore, if a machine is 32-bit, is a pointer in C on that machine always 4 bytes (32 bits)?

Was it helpful?

Solution

In modern, high-performance, generally available CPUs (read, x86), the N-bit architectural distinction refers to width of the data operated upon by the architecturally preferred integer operations. These CPUs contain registers of many different sizes, however, some which can pack multiple data values into one register as one would use with SIMD instructions.

The relationship between memory address space and this N-bit architectural distinction simply comes from the fact that once 32bits could fit in a single register, memory offset calculations could be performed in a single cycle, and 32bits seemed like enough address space for the foreseeable future. Eventually, that foreseeable future expired, and now we perform memory offset calculations with 64bit values in a 64bit address space.

This relationship with address space is somewhat arbitrary and was based upon that fact that these values became large enough to provide a reasonable amount of memory. In 12-bit minicomputers for example, memory was not limited to (2^12) 4096 bytes, memory address simply spanned multiple registers and offset calculations took more than once cycle. The same approach is used today with some 8-bit microcontrollers, the type you would find in a microwave oven. They may provide a 16-bit address space, 64kB of memory, by storing addresses in two registers rather than one.

So, unless you're dealing with non-mainstream CPUs, you can consider the N-bit distinction the address space. However, there are cases even today, where this doesn't map. For example microcontrollers, as mentioned, and domain specific or supercomputing architectures which may use "Very Large Instruction Words", that could be considered "2048-bit CPUs" but most likely operate in a 64-bit address space.

OTHER TIPS

There is nothing that says that the width of the ALU, address bus and data bus all have to be the same. Thus there is no formal definition of what it means to be e.g. 32-bit.

Furthermore, if a machine is 32-bit, is a pointer in C on that machine always 4 bytes (32 bits)?

You can use auto-multiplexer to address 12GB using only 32bits.(very inefficient because only 1/3 of the cycles are accessing a 4GB region)

  *****************************************************************
  Multiplexer clock cycle1



                            first 4GB
  32-bit wide addressing     /
 ---------------------------M----
                             \

  *************************************************************
  Multiplexer clock cycle2




  32-bit wide addressing     /
 ---------------------------M----- second 4GB
                             \


  **************************************************************
  Multiplexer clock cycle3




  32-bit wide addressing     /
 ---------------------------M-----
                             \
                           third 4GB

In the instructions design, you do:

 waitFor(multiplexer%3==0)write value to address;// you know this writes to first 4GB region
                                            //blocks until multiplexer is ready
  waitFor(multiplexer%3==1)write value2 to address;// you know this writes to second 4GB region
                                             //blocks until multiplexer is ready
  waitFor(multiplexer%3==2)write value3 to address;// you know this writes to last 4GB region
                                            //blocks until multiplexer is ready

 Multiplexer value can be accessed by a cpu register easily.

So, the answer is no. It can be lesser than 32 bits.

Modern Operating Systems and computers use a construct called Virtual Memory. Each program (process) thinks it has the entirety of your RAM at its disposal. In reality, RAM is shared among many concurrent processes.

Typically, the "address" you see in your compiler is not equivalent to the address within RAM or a physical address (PA). It is instead a "virtual address" (VA). The OS together with your processor will translate VAs into PAs.

Why do this? Because your RAM often is too small to be addressed by 64-bits or 32-bits. 2^64 is in Zetabytes! No RAM is that large! Think of RAM as a high level cache to your hard-disk: we only take the small parts of the currently running programs from disk into RAM when we need to use them.

If the piece of your program needed is not in RAM, then a "page fault" will trigger, bringing the needed data into RAM from disk, and kicking out some old, unused data from RAM in doing so.

To answer your question: The amount of RAM your computer can handle then, is (almost) entirely independent of the length of your virtual addresses in bits. Take a server rack with 128 GB of RAM for example. What is the benefit of all that RAM?! The benefit is that you will be able to run multiple processes in parallel and still have everything running very fast.

This is a big topic in Computer Architecture. Read what you can about Virtual Memory, Paging and Page Tables, and Memory Organization to get a better understanding.

Hope this helps!

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top