linux-c-programming.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: ratheesh k <ratheesh.ksz@gmail.com>
To: "Steve Graegert (スティーブ)" <graegerts@gmail.com>
Cc: Jonathan Isom <jeisom@gmail.com>,
	Michal Nazarewicz <mina86@mina86.com>,
	linux-c-programming@vger.kernel.org
Subject: Re: same pid ?
Date: Fri, 11 Feb 2011 12:49:23 +0530	[thread overview]
Message-ID: <AANLkTimuBfJUTiL_gu8-me9ViVvNBt5DYG5ZwOS8+BKg@mail.gmail.com> (raw)
In-Reply-To: <AANLkTinNi8QLzALkr0c=F6t=26-c-g-_bW1=k9yNkoR+@mail.gmail.com>

2011/2/11 Steve Graegert (スティーブ) <graegerts@gmail.com>:
> POSIX.1 requires threads to share a couple of attributes (mainly
> process attributes) like the process ID, open FDs and many others.
> What you are referring to ("everything as task") is the fact that each
> thread is associated with a single scheduling entity within the kernel
> implementing a 1:1 mapping.  Yet, threads created within the same
> process share a single PID.
>

Thanks steve.

I found some more info. posix thread uses CLONE_THREAD with clone()
system call.
i quoted from - man clone

CLONE_THREAD (since Linux 2.4.0-test8)
    If CLONE_THREAD is set, the child is placed in the same thread
group as the calling process. To make the remainder of the discussion
of CLONE_THREAD more readable, the term "thread" is used to refer to
the processes within a thread group.

    Thread groups were a feature added in Linux 2.4 to support the
POSIX threads notion of a set of threads that share a single PID.
Internally, this shared PID is the so-called thread group identifier
(TGID) for the thread group. Since Linux 2.4, calls to getpid(2)
return the TGID of the caller.

-Ratheesh



> On Fri, Feb 11, 2011 at 03:18, ratheesh k <ratheesh.ksz@gmail.com> wrote:
>>>On Fri, Feb 11, 2011 at 4:56 AM, Jonathan Isom <jeisom@gmail.com> wrote:
>>> Newer distros use Native POSIX Thread Library (NPTL).  They return the same pid.
>>
>> if linux treats every thing as task (both thread and process ) and
>> CLONE_PID flag is obsolete, i expected unique pid.
>

> You are advised to consult pthreads(7) to make yourself familiar with the topic.
>
> Steve
>

  reply	other threads:[~2011-02-11  7:19 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <AANLkTincdyMFR2Yb-HVvKmqoVTyTvSXweM5K_WLzFijC@mail.gmail.com>
2011-02-10 11:37 ` same pid ? ratheesh k
2011-02-10 12:22   ` Michal Nazarewicz
2011-02-10 18:09     ` ratheesh k
2011-02-10 23:26       ` Jonathan Isom
2011-02-11  2:18         ` ratheesh k
2011-02-11  5:12           ` Steve Graegert (スティーブ)
2011-02-11  7:19             ` ratheesh k [this message]
2011-02-11  9:02               ` ratheesh k

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=AANLkTimuBfJUTiL_gu8-me9ViVvNBt5DYG5ZwOS8+BKg@mail.gmail.com \
    --to=ratheesh.ksz@gmail.com \
    --cc=graegerts@gmail.com \
    --cc=jeisom@gmail.com \
    --cc=linux-c-programming@vger.kernel.org \
    --cc=mina86@mina86.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).