I have a query related to the implementation of threads in Linux.

Linux does not have an explicit thread support. In userspace, we might use an thread library (like NPTL) for creating threads. Now if we use NPTL it supports 1:1 mapping.

The kernel will use the clone() function to implement threads.

Suppose I have created 4 threads. Then it would mean that:

  • There will be 4 task_struct.
  • Inside the task_struct, there will be provision of sharing resources as per the arguments to clone (CLONE_VM | CLONE_FS | CLONE_FILES | CLONE_SIGHAND).

Now I have the following query:

  1. Will the 4 threads have the same PID? If someone can elaborate, how the PIDs are shared.
  2. How are the different threads identified; is there some TID (thread ID) concept?
Edit
Report