Reputation: 21
I have a simple question regarding Linux.
Let us Suppose we have 1GB RAM. I read that Out of this 1GB RAM
1GB RAM is itself divided into High Mem and Low mem High Mem is 128MB and Low Mem is 896MB (Both are 1GB total)
My Question is Where is the 0x0GB to 3GB data mapped into RAM
1) user space is 3GB - Where does it reside in the RAM? If the 896 MB + High is already occupying the entire RAM. Where is the space for the Userspace 3GB RAM?
4GB +---------------+-------------+
| 128MB | |
+---------------+ <------+ |->|------------+
| 896MB | | | 128MB |
3GB +---------------+ <--+ +------>+------------+
| | | | 896 MB |
| ///// | +---------->+------------+
| |
0GB +---------------+
Upvotes: 2
Views: 1158
Reputation: 12337
You're confusing different concepts. The [0-3GB] + [3-4GB] areas are in virtual address space (and that particular layout is very specific to i386 [i.e. x86 32-bit], btw).
If you have 1GB of RAM, the available physical memory is mapped via the virtual address space. It is possible (and in many cases, likely) for the same physical page of memory to be mapped more than once.
By default, in i386, the low 896MB of RAM is direct-mapped into kernel virtual address space starting at the 3GB mark (0xc0000000). The lowest several megabytes is actually used by the kernel for its code and data areas. Most of the rest is then placed into allocation pools where it can subsequently be allocated for use by the kernel or by user processes.
So, user virtual address space uses some of the same physical memory. Physical pages are allocated one-by-one as needed by a process and mapped into the low 3GB of virtual space. This mapping changes every time there is a context switch. That is, process A's virtual address space maps different sets of pages than process B's -- except that the kernel part (above 0xc0000000) will not change.
When actually executing code, every code or data address used in the program is a virtual address. The virtual address gets translated to a physical address in hardware by page tables. The kernel sets up and completely controls the page tables.
Upvotes: 3