Introduction to the Linux kernel boot process

Source: Internet
Author: User

Chen Tie + Original works reproduced please specify the source + "Linux kernel analysis" MOOC course http://mooc.study.163.com/course/USTC-1000029000


In fact, for Linux is very familiar with, the last five years of work computer installed Ubuntu system, because after all, the work of Windows still inseparable, so on the host virtual Windows XP system, to solve the need to work with Windows. In spite of this, the boot process of the kernel does not know, just see the boot process output information, and then wait for the shell landing interface. This time through learning, but also a little understanding, the teacher asked the experimental process record, but also deepen their impressions.

The computer in the virtual machine is not successful, and finally the environment of the laboratory building is used, and the analysis process is recorded:

Start the debug mode directly. The system stops before the kernel loads.

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/5B/7E/wKioL1UKkNizN6ktAAF_bZQweN4119.jpg "title=" TS. PNG "height=" 294 "width=" 706 "alt=" wkiol1ukknizn6ktaaf_bzqwen4119.jpg "/>

Press Ctrl+shift+t to open another terminal window. Start GDB, load the kernel code, and connect to remote port 1234.

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/5B/84/wKiom1UKkLqzFjbEAAE0l1TvVOY867.jpg "title=" gdb. PNG "alt=" Wkiom1ukklqzfjbeaae0l1tvvoy867.jpg "/>

Set breakpoints Break Start_kernel,c command to continue execution, you can see the Virtual Machine Boot window, the operating system stops at booting the kernel.

Execute the list command in GDB to see the code that is currently executing.

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M02/5B/85/wKiom1UKk7jjHM-YAAKGigLP4IU127.jpg "title=" Startkernel. PNG "height=" 321 "width=" 698 "alt=" wkiom1ukk7jjhm-yaakgiglp4iu127.jpg "/>

Execute the list command several times, you can see the initialization function in the Start_kernel, some names explain the function, and the code is also described at the beginning. Such as

Boot_cpu_init ();

Page_address_init ();

Trapf_init ();

Memory Management Initialization

Mm_init ();

The core Process Scheduler is initialized with a priority higher than any interrupt, initializing process 0, which is the idle process

Sched_init ();

INIT_IRQ ();

Init_timer ();

Console_init ();

Pidmap ();

Task System Initialization

Cred_init ();

Buffer_init ();

Key_init ();

Then set a breakpoint break Rest_init,c command to continue with the following:

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/5B/85/wKiom1UKmFLhd3TZAAT2GHOfgBE995.jpg "title=" rest. PNG "height=" 343 "width=" 712 "alt=" wkiom1ukmflhd3tzaat2ghofgbe995.jpg "/>

Directly after the start-up process, the teacher has modified the simple interface menuos. You can execute 3 commands, and other inputs will prompt "This is a wrong cmd!

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/5B/85/wKiom1UKmrGhFglnAAI7y_P8DUQ125.jpg "title=" menuos . PNG "height=" 371 "width=" 641 "alt=" wkiom1ukmrghfglnaai7y_p8duq125.jpg "/>

In summary, the Linux kernel launches a boot program grub that loads kernel code (kernel image) into memory, takes control of the system, executes the corresponding code in the Start_kernel, completes various initialization processes of the system, and enters the idle process, which is the 0 good process. You cannot see it in the list of Linux processes, and then call Init as the system's number 1th process to complete the setup of the system environment. The init process becomes the parent process of all processes, enters the human-computer interaction mode, and the familiar interface appears, completing the kernel boot.

This article is from the "Studypark" blog, make sure to keep this source http://swordautumn.blog.51cto.com/1485402/1622315

Introduction to the Linux kernel boot process

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.