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