In linux, because the bases of segments are all 0, so the logical address coincide with the linear address (Book "Understanding the linux kernel"). I think the logical address of different process may be the same, so the linear address of different process may be the same and as each process view 4GB, each process will have its own linear address space (local address space). But some other articles says there is a large linear address space shared by all process, and the segment mechanism is used to map different process into different part of the linear address space. Sounds like a global linear address space with wider address bits. Where am I wrong? Or they are used in different architecture?
-
From which point of view are you asking the question: from inside the kernel (e.g. when coding a new kernel module), or from inside application (e.g. when coding Linux applications)? – Basile Starynkevitch Jul 28 '12 at 11:15
-
1I want to know the principle and mechanism of Linux. Especially how linux use the features provided by hardware, e.g. , CPU. – user1559088 Jul 28 '12 at 11:38
-
I carefully gave a lot of references in my reply. *Each reference should be useful to you*. – Basile Starynkevitch Jul 28 '12 at 11:45
2 Answers
Each Linux process has its own address space; it is virtual memory. Different processes have different address spaces (but all the threads inside a process share the same address space).
You can get a map of process 1234
on Linux by reading /proc/1234/maps
or from inside the process /proc/self/maps
Try the following commands
cat /proc/$$/maps
cat /proc/self/maps
and think about their output; the first command shows the memory map of your shell; the second one shows the memory map of the process running cat
The address space is set with execve(2) at program startup and changed with the mmap(2) and related syscalls.
An application interact with the kernel only thru syscalls. The kernel has a "different" address space, which you should not care about (unless you are coding inside the kernel).
Read also a good book like Advanced Unix Programming and/or Advanced Linux Programming
See also this explanation on syscalls.
Notice that segmented addressing is specific to i386 and is obsolete: most systems don't use it anymore. It has completely disappeared in 64 bits mode of x86-64. All Linux systems use a flat memory model
Please read carefully all the references.

- 1
- 1

- 223,805
- 18
- 296
- 547
-
Does this mean that Linux makes logical (also virtual?) address of a process to be the same of its linear address and only separates different process by paging? – user1559088 Jul 28 '12 at 07:02
-
I don't understand what you mean by "linear address" (linux don't use segment addressing, an old useless pecularity of i386 not used in x86-64 or in other processors). Did you read all the references I gave you? – Basile Starynkevitch Jul 28 '12 at 07:33
-
Yes. I was just confused about the three address introduced in the book. Now, I should say that in Linux, process can see virtual address directly, which are translated to physical address by paging, right? – user1559088 Jul 28 '12 at 10:59
-
You should not care about physical address from the point of view of an application; you only care about physical addresses inside the kernel, e.g. if hacking the kernel or a kernel module. User-code applications don't care about physical addresses. – Basile Starynkevitch Jul 28 '12 at 11:03
-
You are right. But I want to know the principle or mechanism used by linux. For 8086 CPU, logical and linear address are two conception, but Linux don't use segment, so their values are the same. Then, can I say that each process can only see their own virtual address space directly, which related to physical by paging? – user1559088 Jul 28 '12 at 11:19
Intel support 3 kinds of addresses:
logical address --(segment unit)---> linear address ---(paging unit)---> physical address
as you know, all kernel and user code access data or text thought virtual address (logical address in CPU). The address is translated into linear address as the following graph:
As linux implementation does not support the concept of linear addressing and the segments is only provided for permission control. Linux kernel configures each segment's offset value to zero. That is why you can't see the linear address in kernel and kernel directly use virtual address on paging units.
After getting the linear address, the MMU paging unit reference CR3 register to get base of paing table to generate physical address.
The same with cpu cache, the paging unit also has a TLB cache per CPU core to speed up the address translation that performed on memory.
Reference: intel64 software developer's manual

- 2,674
- 25
- 32