"Learning Notes" in-depth understanding of the third edition of the Linux kernel-Chapter III process

Source: Internet
Author: User

What is a process

Process (shared resource unit)/thread (executing unit)/lightweight process (shared partial resource)

Linux threads are implemented through the Pthead standard library, where lightweight processes are implemented and methods can be executed against thread groups.

Static: How the process describes

Process Descriptor: Task_struct data type

The process corresponds to the process descriptor one by one. The process descriptor pointer points to the process descriptor address from which the kernel references the process.

The PID (process ID) can be used to identify the process (Linux maintains the Pidbitmap-array bitmap to manage the assigned PID), and the same thread group's threads use the same PID (the same value as the first thread).

Process Execution Status: the hardware layer will thread_info and process kernel stack data ( stack of the process descriptor, the original use of two-way list maintenance process linked list, multiple running process list corresponding to different priorities) put together, The Thread_info data for the CPU running process can be obtained through hardware fetching.

Inter-process relationships: hash tables (hash conflicts are resolved by bidirectional lists) maintain different relationships between processes (Linux needs to operate on different units, such as process groups)

Process wait queue: doubly linked list process linked list, process descriptor pointer, description can be awakened way

Maximum resource limit in process usage: stored by RLIMIT structure

Dynamic: Process-related actions (toggle/create/delete)

Toggle (Context context/process process/task toggle)

The part of the data on which the process execution depends is required to be stored in a register (TSS or kernel-state stack), which is referred to as the hardware context. Linux maintains a TSS for each CPU, storing only the hardware context of the running process and not storing it in the corresponding process address space when it is run. switch_to function

Create

Traditional UNIX: Child processes copy the entire address space of the parent process

Modern Unix:

Clone ()/copy_process ()/do_fork ()

Undo Process

The process terminates, exit (), and frees the C function library to allocate resources. There are two ways of terminating a thread group (do_group_exit) and terminating a thread (do_exit).

Delete process: The parent process needs to know the result of the child Process Execution (dead); If the parent process dies first, the orphan process becomes a child of the INIT process, and the processing is removed by the init process wait ().

Kernel threads

Thread 0:linux The initialization phase of a process created from scratch, the idle process

Thread 1: Thread 0 created, shared kernel data structure, init ()

Other: Importance cycle background tasks, such as refreshing cache etc.

"Learning Notes" in-depth understanding of the third edition of the Linux kernel-Chapter III process

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.