A deep understanding of Linux memory ing mechanism

Source: Internet
Author: User
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:

  

$ Content $ nbsp; make
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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.