Li Yajian "Linux kernel Analysis" MOOC course http://mooc.study.163.com/course/USTC-1000029000
first, the experimental process :
Experimental content starts with the GDB trace debug kernel from Start_kernel to init process
1. According to the experimental guidance according to the process, in the laboratory building environment Open the shell:
CD linuxkernel/
Qemu-kernel linux-3.18.6/arch/x86/boot/bzimage -initrd rootfs.img
Enter the help command:
2. Use GDB to trace the debug kernel:
Qemu-kernel linux-3.18.6/arch/x86/boot/bzimage -initrd rootfs.img-s-S
3. Open a separate Shell window and enter the GDB command:
To set breakpoints:
4. Enter the list directive:
Second, the analysis of the Start_kernel function of the execution process
The Start_kernel () function completes the initialization of the Linux kernel. Each kernel component is initialized with this function.
1. Call the Sched_init () function to initialize the scheduler
2. Call the Build_all_zonelists () function to initialize memory management
3. Call the Page_alloc_init () function to initialize the partner system assignment program
4. Call the Trap_init () function and the INIT_IRQ () function to initialize the IDT
5. Call the Softing_init () function to initialize the TASKLET_SOFTIRQ and HI_SOFTIRQ (soft interrupt)
6. Call Time_init () to initialize the system date and time
7. Call the Kmem_cache_init () function to initialize the slab allocator (normal and cache)
8. Call the Calibrate_delay () function to determine the CPU clock (delay function)
9. Call the Kernel_thread () function to create an internal thread for process 1, which will create additional kernel threads and execute the/SBIN/INIT program
10. The Linux version is displayed after Start_kernel (), and in addition, many additional information is displayed in the final phase of the INIT program and kernel thread execution. Finally, a familiar login prompt appears on the console informing the user that the Linux kernel is up and running.
Third, the "Linux system startup Process" understanding.
1. As the Monensin teacher video says, Process 1, also known as the Init process, is the ancestor of all user processes called by process 0 at Start_kernel Rest_init to create the init process PID 1, when the scheduler chooses to the INIT process, The init process starts executing the kernel_init () function init is a common user-state process, which is the interface between the UNIX system kernel initialization and user-state initialization, which is the ancestor of all user processes. Before running INIT, the kernel initialization, the last action of the process (kernel initialization) is to run the/sbin/init executable. In general, this is where almost every subsystem is born. The 2.idle process, as the title says, completes the initialization of important subsystems and takes a backseat. Process 1th from the No. 0 process fork out, and then switch to the user state, complete control from the kernel mentality to the user state conversion, so user interaction can begin.
Trace analysis of the boot process of the Linux kernel