Job Title:
Detailed analysis of the process initiated from Start_kernel to Init process and the combination of experiments to write a signed blog, and in the blog post "real name (and the name of the final application certificate must be consistent) + Original works reproduced please specify the source +" Linux kernel Analysis "MOOC Course/http mooc.study.163.com/course/ustc-1000029000 ", the specific requirements of the blog content are as follows:
Topic self-proposed, the content revolves around the Linux kernel boot process, namely starts from Start_kernel to the INIT process;
You need to use an experiment in your blog
The execution of the Start_kernel function needs to be carefully analyzed in the blog content
The summary section needs to clarify its understanding of the "Linux system startup process", especially how the idle process, process 1th is coming.
Answer area:
1. Open the shell using the virtual machine of the lab building and enter the following command:
cd LinuxKernel/qemu -kernel linux-3.18.6/arch/x86/boot/bzImage -initrd rootfs.img
2. Using GDB to trace the debug kernel
qemu -kernel linux-3.18.6/arch/x86/boot/bzImage -initrd rootfs.img -s -S # 关于-s和-S选项的说明: -S freeze CPU at startup (use ’c’ to start execution) -s shorthand for -gdb tcp::1234 若不想使用1234端口,则可以使用-gdb tcp:xxxx来取代-s选项
3. Open another Shell window
gdb(gdb)file linux-3.18.6/vmlinux # 在gdb界面中targe remote之前加载符号表(gdb)target remote:1234 # 建立gdb和gdbserver之间的连接,按c 让qemu上的Linux继续运行(gdb)break start_kernel # 断点的设置可以在target remote之前,也可以在之后
4. The above steps are as follows:
5. Start_kernel function Execution Process:
1 lockdep_init ();2Set_task_stack_end_magic (&init_task);//Init_task is the pcb,0 process that was created manually, which is the final idle process. 3 smp_setup_processor_id ();4 debug_objects_early_init ();5 // ...6Trap_init ();//Interrupt Initialization Vector7Mm_init ();//memory Management Weird initialization8Sched_init ();//initialization of process scheduling9 // ...TenRest_init ();//START process # 1th
6. Understanding of the "Linux system startup Process":
Regardless of which part of the analysis kernel will be involved in Start_kernel. The call is initialized by Start_kernel.
The init process is the first user-state process, called process 1th. Rest_init function---kernel_init function---run_init_process, find the program under the root directory as "process number 1th."
Dispatched to the idle process when no process is required for the system to execute. This is "process number No. 0". has been in existence since the system was booted. It created the 1th process "kernel_init" and other processes. So the system starts up.
Li Chunlin
Original works reproduced please indicate the source
"Linux kernel Analysis" MOOC course Address: http://mooc.study.163.com/course/USTC-1000029000
(Job 3) The boot process of the Linux kernel (starting from Start_kernel to Init process)