Linux Kernel: note

1. Each process in Linux has two stacks, a user stack and a kernel stack (8KB by default)

2.  thread_info is architecure dependent but task_struct is generic

3. fork call chain:

  libc fork()

    system_call (arch/i386/kernel/entry.S)

      sys_clone() (arch/i386/kernel/process.c)

        do_fork() (kernel/fork.c)

          copy_process()  (kernel/fork.c)

            p=dup_task_struct(current)   //shallo copy

            copy_*                                  //copy point-to structures

            copy_thread()                       //copy stack, regs, and eip

          wait_up_new_task()                 //set child runnable 

4. exit() call chain

libc exit(...)

    system_call (arch/i386/kernel/entry.S)

      sys_exit()  (kernel/exit.c)

        do_exit()  (kernel/exit.c)

          exit_*()                     //free data stuctures

          exit_notify()               //tell other process we exit

                    //reparent children to init if EXIT_ZOMBIE or EXIT_DEAD

5. context switch call chain

  schedule()   (kernel/sched.c)

    context_switch()

      switch_mm (include/asm-i386/mmu_context.h)

      switch_to (include/asm-i386/system.h)

        __switch_to (arch/i386/kernel/process.c)

useful links:

http://www.cs.columbia.edu/~junfeng/10sp-w4118/lectures/l07-proc-linux.pdf

时间: 2024-12-16 19:39:36

Linux Kernel: note的相关文章

Linux Kernel - Debug Guide (Linux内核调试指南 )

http://blog.csdn.net/blizmax6/article/details/6747601 linux内核调试指南 一些前言 作者前言 知识从哪里来 为什么撰写本文档 为什么需要汇编级调试 ***第一部分:基础知识*** 总纲:内核世界的陷阱 源码阅读的陷阱 代码调试的陷阱 原理理解的陷阱 建立调试环境 发行版的选择和安装 安装交叉编译工具 bin工具集的使用 qemu的使用 initrd.img的原理与制作 x86虚拟调试环境的建立 arm虚拟调试环境的建立 arm开发板调试环

Linux snacks from <linux kernel development>

introduction to the Linux kernel 1.operating system 1) considered the parts of the system 2) responsible for basic use and administration. 3) includes the kernel and device drivers, boot loader, command shell or other user interface, and basic file a

Android linux kernel privilege escalation vulnerability and exploit (CVE-2014-4322)

In this blog post we'll go over a Linux kernel privilege escalation vulnerability I discovered which enables arbitrary code execution within the kernel. The vulnerability affected all devices based on Qualcomm chipsets (that is, based on the "msm&quo

Linux Kernel HomeWork---/proc/mtest

Memory management 1.listvma static void mtest_dump_vma_list(void) { struct task_struct *task = current;                //get the task_struct of the current process struct mm_struct *mm = task->mm; struct vm_area_struct *vma;                //get the

video : Write and Submit your first Linux kernel Patch

http://v.youku.com/v_show/id_XNDMwNzc3MTI4.html After working with Linux (mostly as an advanced user) for years, I decided to post my first p=linux/kernel/git/x86/linux-2.6-tip.git;a=commitdiff;h=e19e074b1525d11a66c8e3386fec7db248ad3005" style="

How to: Compile Linux kernel 2.6

  Compiling custom kernel has its own advantages and disadvantages. However, new Linux user / admin find it difficult to compile Linux kernel. Compiling kernel needs to understand few things and then just type couple of commands. This step by step ho

[Quote] New subsystem iio in Linux Kernel.

So, here comes the iio subsystem new to Linux Kernel, at least for me, present for for supporting some of the composite sensors in Android. Some introductions and some basic infos about it. Introduce IIO interface for Android advanced features iio-a-

linux内核可以接受的参数 | Linux kernel启动参数 | 通过grub给内核传递参数

在Linux中,给kernel传递参数以控制其行为总共有三种方法: 1.build kernel之时的各个configuration选项. 2.当kernel启动之时,可以参数在kernel被GRUB或LILO等启动程序调用之时传递给kernel. 3.在kernel运行时,修改/proc或/sys目录下的文件. 这里我简单讲的就是第二种方式了,kernel在grub中配置的启动参数. 首先,kernel有哪些参数呢? 在linux的源代码中,有这样的一个文档Documentation/kern

Linux Kernel的Makefile与Kconfig文件的语法

https://www.kernel.org/doc/Documentation/kbuild/kconfig-language.txt Introduction ------------ The configuration database is a collection of configuration options organized in a tree structure: +- Code maturity level options | +- Prompt for developme