Intro
Linux, like most modern operating systems, uses virtual pages provided by most modern architectures, including the x86 family.
In a system with virtual memory, the physical memory (actual RAM resource) is abstract from the process running on the system. An address space is just all the numbers where memory could be.
Paging
Memory can be mapped (put at an address) in pages which is the architecture dependent size of a memory chunk. So if you want to put memory at some address so the process can use it, then you'd have to pick a page aligned number (a multiple of the page size) and place at least one page there.
Protection
Virtual memory also allows for memory protection which sets what permissions the process will have. When a process's executable memory is mapped (the instructions it executes to do stuff) it is read/execute only. This means that the processor can execute that memory, and you can read it, but you can't write to it.
When a process is loaded from disk (in Linux with the exec
system call) it is placed in memory with several regions of memory already mapped. These regions are the executable code from the program, data sections, and stack. The process can request more memory to be mapped later by using the mmap
or brk
system calls.
When a process tries to access memory it does not have mapped, it triggers the infamous SEGFAULT
error, and the kernel will kill your program. Other times, the hardware will fault but the program does have memory mapped, this is because the kernel unmapped it to save it until it is needed. What happens here is the process stops running, the kernel remaps the memory, and your process starts running again like nothing happened.
Address Space
So the size of the address space is just the upper limit of the memory you could have if the program had mapped every address it possibly could to actual RAM memory.
The one gig address space to the kernel part is about the process's meta-data that the kernel keeps track of. For instance, it will keep a listing of open files, and mapped memory in the process headers. It will also keep thread headers there. Again, all of it is not mapped, only what it needs.
Note that each process has its own universe of addresses, it never sees what another process has mapped at those addresses. This way, the process can act as if it is the only process on the machine, mapping memory to any address it chooses.
Also note, the 4gb number is because the hardware that does addressing supports only 32 bit numbers, the largest number one can hold in a 32 bit number is 2^32 = 4,294,967,296. This is 4 gb. So one can only map 4gb of addresses to memory.
This is just a crappy intro, please do some googling on virtual memory.