Review
1.中断上下文的切换——保存现场&恢复现场
Main course content of this section introduction to Linux kernel source code
1. Open the Kernel source code page
arch/目录:支持不同CPU的源代码;其中的X86是重点init/目录:内核启动相关的代码基本都在该目录中(比如main.c等)start_kernel函数就相当于普通C程序的main函数kernel/目录:Linux内核核心代码在kernel目录中
Readme
介绍了什么是Linux,Linux能够在哪些硬件上运行,如何安装内核源代码等
Construct a simple Linux system menuos Trace Analysis of the boot process of the Linux kernel
Boot Kernel init is the first user-state process, which is process number 1th.
Debug kernel with gdb trace about parameters-s,-s:
- S是指在CPU初始化之前(刚启动的时候)将其冻结- s是指在1234这个端口上创建的gdb server
Steps:
输入gdb之后,gdb即被打开;加载Linux符号表;连接到刚刚被冻结的Linux系统;可以设置断点(break),格式为:break [函数名](此时系统还是被冻结而并没有启动的);设置完断点之后,输入c命令continue(继续执行),函数会停在断点处;输入list指令之后,可以详细地查看函数停留的位置
Simple analysis of Start_kernel
- Init_task is the final idle process of the pcb,0 process, which was created manually.
- No matter what part of the analysis kernel will involve Start_kernel
- Reference Code HTTP://CODELAB.SHIYANLOU.COM/XREF/LINUX-3.18.6/INIT/MAIN.C
- Initialization of many modules
- Daosh One or one born two or two three or three living things.
Related information
Linux kernel boot process overview The startup process of the x86 CPU starts with the first action cs:eip=ffff:0000h (converted to a physical address of 000ffff0h because the 16-bit CPU has 20 address lines), which is the location of the BIOS program. After the http://wenku.baidu.com/view/4e5c49eb172ded630b1cb699.html BIOS routine detects the hardware and completes the corresponding initialization, it looks for the bootable media, and after locating the bootloader into the specified memory area, The control is given to the boot program. This is usually the first sector of the hard disk MBR and the active partition of the boot program loaded into memory (that is, load bootloader), the full load after the control to bootloader. The bootloader bootloader begins to be responsible for operating system initialization and then starts the operating system. The kernel, INITRD, and root partitions and directories are typically specified when the operating system is started, such as Root (hd0,0), kernel (hd0,0)/bzimage Root=/dev/ram init=/bin/ash,initrd ( hd0,0)/myinitrd4m.img The kernel boot process includes start_kernel before and after, all of which are pre-initialized assembly instructions, then start the C code of the operating system initialization, and finally perform the first user-state process init. Generally in two-phase boot, first take advantage of the INITRD memory file system, and then switch to the hard disk file system to continue to boot. There are two main functions of the initrd file: 1, providing boot required but the kernel file (i.e. Vmlinuz) does not provide the driver module (modules) 2, is responsible for loading the hard disk root file system and execute the/SBIN/INIT program, which will continue the boot process
The init process details the INIT task process in the Linux kerneland the idle process Daosh one (startkernel....cpuidle), two lifetimes (kernelinit and Kthreadd), Secondary three (that is, the previous 0, 1 and 23 processes), Sansheng all things (1th process is the ancestor of all user-state processes, the 2nd process is the ancestor of all kernel threads), the core code of the new kernel has been optimized quite clean, all conform to the Chinese traditional culture spirit.
Summarize
Init_task is the final idle process of the pcb,0 process, which was created manually. Daosh One or one born two or two three or three living things. This experiment one step at a time to do or can keep up with, but the network is too slow, open the experimental building is very difficult, wasted a lot of hours, let me feel very depressed.
20135239 Silam Linux kernel analysis trace analysis boot process of Linux kernel