标签:
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
标签:
原文地址:http://www.cnblogs.com/blog-of-walker/p/5450954.html