What decides the space that can be addressed ?

Discussions on more advanced topics such as monolithic vs micro-kernels, transactional memory models, and paging vs segmentation should go here. Use this forum to expand and improve the wiki!
Post Reply
ashwani.raina
Posts: 1
Joined: Wed May 23, 2007 4:57 am
Location: Pune
Contact:

What decides the space that can be addressed ?

Post by ashwani.raina »

Hi all,
I am confused about the whole idea behind the address space that an OS can have. I mean how do we decide that on a 32-bit processor we can address up to 4 GB of memory. I know many of you will tell that 2^32 = 4GB But if I want to address less that that what will happen ?
User avatar
Combuster
Member
Member
Posts: 9301
Joined: Wed Oct 18, 2006 3:45 am
Freenode IRC: [com]buster
Location: On the balcony, where I can actually keep 1½m distance
Contact:

Post by Combuster »

The manufacturers of a processor are the ones that decide how much of memory it can address, and what the size of the address space is, which need not be the same. The amount of addressable memory is theoretically infinite for any processor, but it is usually limited to the size of the address bus (20 bits for 8086, 24 bits for 286, 32 bits for 386dx, 486, pentium, 36 bits for p3/p4, 48 bits for recent 64bit processors) the amount of combinations you can stuff in this amount of bits determine the amount of storage units you can address, which is 2^amount_of_bits, which was a few years ago indeed 4GB, but the currently common processors can address 2^36 or 2^48 units of memory.

On top of that, several systems can change the behaviour of the address bus so that certain addresses can go to different locations. you could have two sets of 4GB memory and use a resource other than the address bus to select which one to use.

Now for the address space, which is a totally different thing. Many processors are equipped with a memory management unit (MMU). When a program asks for a certain memory location, the MMU translates that location to the appropriate value that is presented on the address bus, which will in turn activate a unit of memory, or some other device that is wired to it. The address space is the area of memory that is presented to the program. The size of the address space is itself linked to the size of the registers. This is because you provide the processor with the desired memory address which has to come from some location, usually a register. On 32 bit machines, you have 32 bits to select an address, so the address space is 2^32 (the amount of unique values you can assign to 32 bits) units of memory = 4GB.
On processors without MMU, the provided address is forwarded directly to the address bus, so that the size of the address space equals that of the address bus (which commonly equals the amount of addressable memory). However, there is more: on an 8086 the size of the register is 16 bits, but the address space is 20 bits. This is because the processor adds two registers together to form the address. This second register is called the segment register. Other processors have again different methods to generate addresses. (As an example, IIRC the Z80 concatenates 2 8-bit registers to form one 16-bit address)

If you want to address less memory, that is your decision. Basically that you CAN address 4GB does not mean that you WANT to. You just end up not using everything that is potentially available.

[edit](remarked by JAAman) Forgot the 286s protected mode[/edit]
Last edited by Combuster on Mon May 28, 2007 11:10 am, edited 1 time in total.
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
User avatar
JAAman
Member
Member
Posts: 877
Joined: Wed Oct 27, 2004 11:00 pm
Location: WA

Post by JAAman »

(20 bits for 8086, 286, 32 bits for 386,486,pentium, 36 bits for p3/p4, 48 bits for recent 64bit processors)

for the sake of accuracy, i must point out that:
286 -- 24bits (not 20)
386SX -- 24bits -- while the 386 did have a 32bit address bus, the 386SX only had a 24bit address bus -- same as the 286
Post Reply