码迷,mamicode.com
首页 > 系统相关 > 详细

Linux Kernel: note

时间:2016-05-01 20:20:56      阅读:191      评论:0      收藏:0      [点我收藏+]

标签:

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

Linux Kernel: note

标签:

原文地址:http://www.cnblogs.com/blog-of-walker/p/5450954.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!