Linux Kernel:note

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.