1. Each process in Linux have 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