内核的启动过程
来源:互联网 发布:photoshop cs6 for mac 编辑:程序博客网 时间:2024/06/10 08:38
内核的启动过程——Linux内核分析课程
主要了解了CPU内核源码,看了大概的结构。
cd LinuxKernel/qemu -kernel linux-3.18.6/arch/x86/boot/bzImage -initrd rootfs.img
内核启动完成后进入menu程序
执行结果如图
使用gdb跟踪调试内核
然后就是通过
(gdb)file linux-3.18.6/vmlinux
在gdb界面中targe remote之前加载符号表
(gdb)target remote:1234
建立gdb和gdbserver之间的连接,按c 让qemu上的Linux继续运行
(gdb)break start_kernel
设置断点
下面分析一下代码,了解内核的启动过程
393static noinline void __init_refok rest_init(void)394{395 int pid;396397 rcu_scheduler_starting();398 /*399 * We need to spawn init first so that it obtains pid 1, however400 * the init task will end up wanting to create kthreads, which, if401 * we schedule it before we create kthreadd, will OOPS.402 */403 kernel_thread(kernel_init, NULL, CLONE_FS);404 numa_default_policy();405 pid = kernel_thread(kthreadd, NULL, CLONE_FS | CLONE_FILES);406 rcu_read_lock();407 kthreadd_task = find_task_by_pid_ns(pid, &init_pid_ns);408 rcu_read_unlock();409 complete(&kthreadd_done);410411 /*412 * The boot idle thread must execute schedule()413 * at least once to get things moving:414 */415 init_idle_bootup_task(current);416 schedule_preempt_disabled();417 /* Call into cpu_idle with preempt disabled */418 cpu_startup_entry(CPUHP_ONLINE);419}
这里面包含了三个进程idle,kernel_init,kthreadd。
其中idle进程(PID = 0), kernel_init进程(PID = 1),kthreadd(PID = 2)
kernel_init是所有用户态进程的祖先,kthreadd是所有内核线程的祖先。
三个进程之间的关系
- idle进程由系统自动创建, 运行在内核态;
- kernel_init进程由idle通过kernel_thread创建,在内核空间完成初始化后, 加载init程序, 并最终返回到用户空间;
- kthreadd进程由idle通过kernel_thread创建,并始终运行在内核空间, 负责所有内核线程的调度和管理;
0 0
- 内核的启动过程
- 内核启动过程的配置
- Linux内核的启动过程
- U-Boot启动内核的过程
- Linux内核的引导和启动过程
- U-Boot启动内核的过程
- U-Boot启动内核的过程
- 分析Linux内核的启动过程
- 跟踪分析Linux内核的启动过程
- 分析Linux内核的启动过程
- 跟踪分析Linux内核的启动过程
- 跟踪分析Linux内核的启动过程
- 3.分析Linux内核的启动过程
- 跟踪分析Linux内核的启动过程
- 跟踪分析内核的启动过程(Linux)
- 跟踪分析Linux内核的启动过程
- 跟踪分析Linux内核的启动过程
- Linux 0.11内核的启动过程
- JS变量提升
- 《C++ Primer》读书笔记-第三章 05 数组
- 20169219 linux内核原理与分析第二周作业
- javaweb 解决 Error configuring application listener of class ...
- 20169219linux 内核原理与分析第四周作业
- 内核的启动过程
- 使用库函数API和C代码中嵌入汇编代码两种方式使用同一个系统调用
- Mybatis学习笔记三:实现增删查改
- 谁杀死了MySQL(二)
- mysql查询以前的数据(mysql查询七天前/半小时前等)
- Android开源项目之电脑极客app
- 进程描述和进程的创建
- 《C++ Primer》读书笔记-第三章 06 多维数组
- Android开发——支付宝和微信支付快速接入流程