Construct a simple Linux kernel
Linux is an open source computer operating system kernel, it is written in C language. The main subsystems:
1. the system call interface
2. Process Management
3. Memory Management
4. Virtual File System
qemu is an open source analog processor, in the experiment
cd LinuxKernel/
qemu -kernel linux-3.18.6/arch/x86/boot/bzImage -initrd rootfs.img
qemu need to create a window, it does not work in a pure command system, you need to use the graphical interface of the virtual machine. qemu simulation kernel, bzImage is vmLinux after gzip compressed files, that is, for compressed kernel image. vmLinux is compiled the most original ELF file. Shown below, i.e. using laboratory building process to build a virtual machine environment debugging:
Open another shell window, start gdb debugger breakpoint, as shown:
Set breakpoints in start_kerenl () and rest_init (), press c continues, the results as shown:
start_kernel () is equivalent to the main function c language, assembly language is in addition to the starting point of program execution
start_kernel (), involving almost all the kernel modules:
trap_init (): interrupt vector initialization
mm_init (): memory management initialization
sched_init () : scheduling module initialization
the init_task () (0 process), the process descriptor is used to initialize the macro, and then initialize the other modules of
code is as follows:
the asmlinkage __visible the __init the start_kernel void (void)
{
char command_line;
char after_dashes;
/*
*Need to run as early as possible, to initialize the
*lockdep hash:
*/
lockdep_init();
set_task_stack_end_magic(&init_task);
smp_setup_processor_id();
debug_objects_early_init();
/*
*Set up the initial canary ASAP
*/
boot_init_early();
local_irg_disable();
early_boot_irgs_disabled=TRUE;
}
Summary: 0 cpu_idle process calls after creating the init process (), then part of the One thread is responsible for the implementation of the kernel initialization and system configuration