public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: RVK <rvk@prodmail.net>
To: "J.A. Magallon" <jamagallon@able.es>
Cc: Ian Campbell <ijc@hellion.org.uk>,
	Arjan van de Ven <arjan@infradead.org>,
	Robert Hancock <hancockr@shaw.ca>,
	linux-kernel <linux-kernel@vger.kernel.org>
Subject: Re: Thread_Id
Date: Fri, 15 Jul 2005 11:39:35 +0530	[thread overview]
Message-ID: <42D7531F.5050901@prodmail.net> (raw)
In-Reply-To: <1121382144l.16874l.0l@werewolf.able.es>

J.A. Magallon wrote:

>On 07.14, RVK wrote:
>  
>
>>Ian Campbell wrote:
>>
>>    
>>
>>>On Thu, 2005-07-14 at 16:32 +0530, RVK wrote:
>>>
>>>
>>>      
>>>
>>>>Ian Campbell wrote:
>>>>
>>>>
>>>>        
>>>>
>>>>>What Arjan is saying is that pthread_t is a cookie -- this means that
>>>>>you cannot interpret it in any way, it is just a "thing" which you can
>>>>>pass back to the API, that pthread_t happens to be typedef'd to unsigned
>>>>>long int is irrelevant.
>>>>>
>>>>>
>>>>>          
>>>>>
>>>>Do you want to say for both 2.6.x and 2.4.x I should interpret that way ?
>>>>
>>>>
>>>>        
>>>>
>>>As I understand it, yes, you should never try and assign any meaning to
>>>the values. The fact that you may have been able to find some apparent
>>>meaning under 2.4 is just a coincidence.
>>>
>>>
>>>
>>>      
>>>
>>Iam sorry I don't agree on this. This confusion have created only becoz
>>of the different behavior of pthread_self() on 2.4.18 and 2.6.x kernels.
>>And Iam looking for clarifying my doubt. I can't digest this at all.
>>
>>    
>>
>
>It is simple: none ever never told you that a pthread_t has nothing to do
>with a pid. pthreads is a standard and portable implementation that
>guarantees you can port _pthread_ code between posix systems. It uses
>an internal opaque type to identify threads, but you should never relay on
>it have nothing to do with pids. The fact that somewhere-in-time-in-some-os
>the pthread_t equals the pid/tid/ etc is just pure chance. If you had
>code relaying on this, it is just broken. Where is stated if pthread_t is
>the tid, an index into a table internal to pthread library, a pointer
>to an struct (mmm, bloken on 64 bits?) or what ?
>
>  
>
Understood on pid/tid and thread identifier diffrentiation. The question 
now is why pthread_t is typedef as unsigned long ?

>Whatif:
>- you swith kernels and thread library implementation ?
>- you go solaris (it has user level threads ?)
>
>I think one of the sources of the confussion is that:
>- man pages about system calls talk about 'threads', but that should be
>  read as 'sibling _processes_ created via clone(CLONE_THREAD) syscall'.
>- man pages about phthreads library also talk about 'threads', but that
>  should be read as 'posix threads created via pthread_create'.
>And none guarantees that both 'threads' are the same.
>
>  
>
Yes its very important to have clarity in the manuals on this.

>If you just want to use gettid(), don't go further that clone().
>If you use pthread_create(), forget about gettid().
>
>  
>
Does the man pages for pthread_create or clone or gettid states this ?

rvk

>(AFAIK ;) )
>
>--
>J.A. Magallon <jamagallon()able!es>     \               Software is like sex:
>werewolf!able!es                         \         It's better when it's free
>Mandriva Linux release 2006.0 (Cooker) for i586
>Linux 2.6.12-jam9 (gcc 4.0.1 (4.0.1-0.2mdk for Mandriva Linux release 2006.0))
>
>
>.
>
>  
>


  reply	other threads:[~2005-07-15  6:13 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <4mfcK-UT-25@gated-at.bofh.it>
     [not found] ` <4mUJ1-5ZG-23@gated-at.bofh.it>
2005-07-06  2:47   ` Thread_Id Robert Hancock
2005-07-14  5:33     ` Thread_Id RVK
2005-07-14  7:45       ` Thread_Id Arjan van de Ven
2005-07-14 10:06         ` Thread_Id RVK
2005-07-14 10:30           ` Thread_Id Arjan van de Ven
2005-07-14 11:20             ` Thread_Id RVK
2005-07-14 12:25               ` Thread_Id Arjan van de Ven
2005-07-14 12:39                 ` Thread_Id Jakub Jelinek
2005-07-14 13:08                   ` Thread_Id Benedikt Spranger
2005-07-14 13:49                   ` Thread_Id RVK
2005-07-14 10:39           ` Thread_Id Ian Campbell
2005-07-14 11:02             ` Thread_Id RVK
2005-07-14 11:16               ` Thread_Id Ian Campbell
2005-07-14 11:24                 ` Thread_Id RVK
2005-07-14 23:02                   ` Thread_Id J.A. Magallon
2005-07-15  6:09                     ` RVK [this message]
2005-07-15  6:18                       ` Thread_Id Ian Campbell
2005-07-14 14:28               ` Thread_Id Robert Hancock
2005-07-23 15:02 [PATCH] quieten OOM killer noise Anton Blanchard
2005-07-05 12:15 ` Thread_Id RVK
2005-07-05 12:55   ` Thread_Id Arjan van de Ven
2005-07-07 12:43   ` Thread_Id Benedikt Spranger
2005-07-14  5:31     ` Thread_Id RVK

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=42D7531F.5050901@prodmail.net \
    --to=rvk@prodmail.net \
    --cc=arjan@infradead.org \
    --cc=hancockr@shaw.ca \
    --cc=ijc@hellion.org.uk \
    --cc=jamagallon@able.es \
    --cc=linux-kernel@vger.kernel.org \
    /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