The informations are stored in memory in the task structure called task_struct
associated to each process/thread. All those informations are as usual made available in the pseudo-filesystem /proc
as described in man 5 proc
.
When a process is killed and will disappear, the kernel just parses in memory the list of threads associated to the process (conveniently visible in /proc/[pid]/task/
) to kill them.
The process/thread representation model in linux doesn't separate much between process and thread, they are all tasks. For example they share the same task namespace, as seen in /proc/
which organizes pid (process id) or tid (thread id) the same. But there are differences, eg getpid() will return the thread's pid, while gettid() will return the thread's tid. They can return different values when a thread call them.
Relevant to the question, are those pseudo-files mapping to task_struct contents:
More informations can be seen in man 7 pthreads
with a description of the current NPTL implementation.