Start reading the Linux kernel source code

Source: Internet
Author: User
Start to read the Linux kernel source code-general Linux technology-Linux programming and kernel information. The following is a detailed description. The Linux kernel source code analysis has two good entry points: one is system boot and initialization, that is, from machine power-up to system core running; the other is system calling, system Call is the function interface provided by the user program or operation call core. For those who are familiar with hardware, it may be easier to analyze the system's guidance, it may be more suitable for those who have C programming experience in dos, Uinx, and Linux.

The following uses system guidance and initialization as an example to briefly describe the source code reading clues:

1. system startup and initialization:
In intelbased systems, when loadlin.exe or LILO loads the kernel into the memory and passes control to the kernel, the kernel starts to start. For more information, see arch/i386/kernel/head. S and head. S to set the specific structure and jump to the main () Routine of init/main. c.

2. Memory Management:
The memory management code is mainly in/mm, but the code of the specific structure is in arch/*/mm. The code for page disconnection processing is in/mm/memory. c, while the code for memory ing and page cache is in/mm/filemap. c. Buffer high-speed cache is implemented in/mm/buffer. c, while switching high-speed cache is implemented in mm/swap_state.c and mm/swapfile. c.

3. kernel:
In the kernel, the code of the specific structure is in arch/*/kernel, and the scheduler is in kernel/sched. c. The fork code is in the kernel/fork. c. The kernel routine handler is in include/linux/interrupt. h. The data structure of task_struct is in inlucde/linux/sched. h.

4. PCI:
The PCI pseudo driver is in drivers/pci. c, which is defined in inclulde/linux/pci. h. Each structure has some specific pci bios code. Intel is in arch/alpha/kernel/bios32.c.

In addition, two additional suggestions are added to supplement:
1. Generally, each directory contains one. the depend file and a Makefile file are both auxiliary files used for compilation. reading these two files carefully is helpful for figuring out the relationship and dependency between each file. Moreover, there are also Readme files in some directories, which are descriptions of the files in this directory, which is also conducive to our understanding of the kernel source code;

2. You can start with the start_kernel function, finish with the system calling you are familiar with, and finish with the system calling you are not familiar.

The previous parts of start_kernel are hardware-related. If you want to chase them, you will start to chase them from bootsect. S; the name of the function called by the system is sys _*.

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.