This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: [PATCH] manual: Document thread/task IDs for Linux
On 12/14/18 10:33 AM, Florian Weimer wrote:
> * Carlos O'Donell:
>
>>> +Completion}. (The parent process can arrange for such waiting to
>>> +happen implicitly.) A process ID uniquely identifies a process only
>>> +during the lifetime of the process. As a rule of thumb, this means
>>> +that the process must still be running.
>>> +
>>> +Process IDs can also denote process groups and sessions.
>>> +@xref{Job Control}.
>>> +
>>> +@cindex thread ID
>>> +@cindex task ID
>>> +@cindex thread group
>>> +On Linux, threads created by @code{pthread_create} also receive a
>>> +number form the process ID namespace, a @dfn{thread ID}. The thread
>>
>> s/form/from/g
>
> Fixed, thanks.
>
>> We haven't defined what a "process ID namespace" is in this context,
>> would it be simpler to write:
>>
>> "On Linux, threads created by @code{pthread_create} also receive a
>> unique identifier in the form of a number, a @dfn{thread ID}."
>>
>> or
>>
>> "On Linux, threads created by @code{pthread_create} also receive a
>> unique identifier in the form of a number, a @dfn{thread ID}, which
>> is taken from the set of currently available process IDs."
>
> I see why this is confusing if you come from a Linux namespace
> background. I didn't want to actually refer to Linux namespaces here.
OK. Yes, I thought you were talking about the Linux PID namespace.
> What I wanted to express is that the thread ID is taken from the same
> set that process IDs are drawn from, subject to similar constraints.
> So I wanted to use “namespace” as a shorthand for “the set of available
> names” (although names are really numbers here).
OK, that is what I tried to suggest above. So I think we're on the same
page.
> (I think we should not call these IDs unique because they are not unique
> over time, only at every instant.)
>
> What about this?
>
> On Linux, threads created by @code{pthread_create} also receive a a
s/a //g
> @dfn{thread ID}. The thread ID of the initial (main) thread is the
> same as the process ID of the entire process. Thread IDs for
> subsequently created threads are distinct. They are allocated from
> the same numbering space as process IDs. Process IDs and thread IDs
> are sometimes also referred to collectively as @dfn{task IDs}. In
> contrast to processes, threads are never waited for explicitly, so a
> thread ID becomes eligible for reuse as soon as a thread exits or is
> canceled. This is true even for joinable threads, not just detached
> threads. Threads are also assigned to a @dfn{thread group}. In
s/also//g
> @theglibc{} implementation running on Linux, the process ID is the
> thread group ID of all threads in the process.
Perfect.
Reviewed-by: Carlos O'Donell <carlos@redhat.com>
--
Cheers,
Carlos.