Article Title: a deep understanding of Linux memory ing mechanism. Linux is a technology channel of the IT lab in China. Includes basic categories such as desktop applications, Linux system management, kernel research, embedded systems, and open source.
I. Thread Theory
We often see some address in the program's disassembly code, such as 0x32118965, the operating system CPU linear address, or virtual address. What is the use of virtual addresses? How do I convert a virtual address to a physical memory address? This chapter briefly describes this.
1.1 Linux memory addressing Overview
In the modern sense, operating systems are all in the 32-bit protection mode. Generally, each process can address 4 GB physical space. But our physical memory is usually several hundred mb. How can a process obtain 4 GB physical space? This is the benefit of using virtual addresses. We usually use a technology called virtual memory, because part of the hard disk can be used as memory. Except that the operating system is divided into system space and user space. using virtual addresses can effectively protect kernel space from being damaged by user space.
For how to convert a virtual address to a physical address, the conversion process is completed by the operating system and the CPU. The operating system sets a page table for the CPU. The CPU uses MMU units for address translation.
1.2 kernel code browsing tools
The current kernel is very large, so we need some tool to read the huge source code system. Currently, all kernel development tools use vim + ctag + CSAG to browse the kernel code, makefile files already exist on the Internet to generate ctags, csags, and etags.
I. Usage:
Find an empty directory and copy the attachment Makefile. Then, select the following make command in the directory:
The source files under/usr/src/linux are processed, and ctags and csags are generated in the current directory.
Note: SRCDIR is used to specify the kernel source code directory. If not specified, the default value is/usr/src/linux/
1) only create ctags
| $ Content $ nbsp; make SRCDIR =/usr/src/linux-2.6.12/tags |
2) only create cscope
| $ Content $ nbsp; make SRCDIR =/usr/src/linux-2.6.12/cs.pdf |
3) create ctags and csags
| $ Content $ nbsp; make SRCDIR =/usr/src/linux-2.6.12/ |
4) only create etags
| $ Content $ nbsp; make SRCDIR =/usr/src/linux-2.6.12/TAGS |
[1] [2] [3] [4] Next page