OSDev.org

The Place to Start for Operating System Developers
It is currently Fri Apr 19, 2024 7:03 am

All times are UTC - 6 hours




Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: What decides the space that can be addressed ?
PostPosted: Mon May 28, 2007 7:22 am 
Offline

Joined: Wed May 23, 2007 4:57 am
Posts: 1
Location: Pune
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 ?


Top
 Profile  
 
 Post subject:
PostPosted: Mon May 28, 2007 7:59 am 
Offline
Member
Member
User avatar

Joined: Wed Oct 18, 2006 3:45 am
Posts: 9301
Location: On the balcony, where I can actually keep 1½m distance
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]

_________________
"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 ]


Last edited by Combuster on Mon May 28, 2007 11:10 am, edited 1 time in total.

Top
 Profile  
 
 Post subject:
PostPosted: Mon May 28, 2007 8:47 am 
Offline
Member
Member
User avatar

Joined: Wed Oct 27, 2004 11:00 pm
Posts: 874
Location: WA
Quote:
(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

_________________
## ---- ----- ------ Intel Manuals
OSdev wiki


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: No registered users and 50 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group