Linux kernel--processes, lightweight processes, threads, thread groups

Source: Internet
Author: User

1. Relationships between processes, lightweight processes, threads, thread groups

2, and their identification of the relevant instructions

I. Relationships between processes, lightweight processes, threads, thread groups

With instructions:

The process P0 has four execution streams, that is, threads,

The main thread t0 is the first of its threads and is associated with the process P0.

The T1, T2, T3 Three threads are then derived, and the three threads are associated with the lightweight process P1, P2, P3 one by one.

All processes, lightweight processes, threads make up the thread group.

A lightweight process is also a process, except that it is associated with a particular line threads of a process.

Ii. notes related to their identification

PID is the process identifier, Tgid is the thread group identifier

Each process has its own PID, Medium: Process pid (P0) = A, lightweight process pid (P1) = B/pid (P1) = C/pid (P1) = d.

All processes that belong to one thread group, lightweight processes have the same thread group identifier, and they are the process identifiers associated with the first thread.

For example: the first thread in the diagram is T0, and it is associated with a process of p0,pid (P0) = A, so Tgid (P1) = A/tgid (P1) = A/tgid (P1) = A/tgid (P1) = A.

When we use function Getpid (current_p), the return value is not the PID of Current_p, but its tgid. (Current_p is the current process).

This can be seen from system calls Getpid and Gettid (located in kernel/timer.c).

  long sys_getpid (void)  {    return current->tgid;   long Sys_gettid (void) {   return current->pid;}

Linux kernel--processes, lightweight processes, threads, thread groups

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.