<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: What is thread id thread_t data type in ia64 platform in Operating System - Linux</title>
    <link>https://community.hpe.com/t5/operating-system-linux/what-is-thread-id-thread-t-data-type-in-ia64-platform/m-p/4298652#M62644</link>
    <description>The old linuxthreads implementation used a pthread_t that was an index into an array.  It tended to be a small number.&lt;BR /&gt;&lt;BR /&gt;The more current NPTL linux threads provided by hpde 2.0 use a pthread_t that is a pointer to a struct.&lt;BR /&gt;&lt;BR /&gt;You certainly need to preserve the full size of a pthread_t to reliably use it with pthread_kill.  The high 32 bits of the pthread_t cannot be expected to have a predictable value.  And a later implementation might use a pthread_t with an even larger type.  As noted in "man pthread_equal", the pthread_t type could be a structure in some implementations.</description>
    <pubDate>Mon, 03 Nov 2008 17:37:27 GMT</pubDate>
    <dc:creator>Mike Stroyan</dc:creator>
    <dc:date>2008-11-03T17:37:27Z</dc:date>
    <item>
      <title>What is thread id thread_t data type in ia64 platform</title>
      <link>https://community.hpe.com/t5/operating-system-linux/what-is-thread-id-thread-t-data-type-in-ia64-platform/m-p/4298646#M62638</link>
      <description>Hi,&lt;BR /&gt;   Recently I faced an issue with thread ID. I find whenever I create thread , it always gives me 64-bit long int. And always I find it can not be converted to 32-bit as it will truncate.&lt;BR /&gt;&lt;BR /&gt; I read some topic in google, that thread ID is just not a long int, it can be pointer or structure .&lt;BR /&gt;&lt;BR /&gt;May I know what exactly thread ID is in below platform type ?&lt;BR /&gt;Linux Node2 2.6.10-telco-1.46-mckinley-smp #1 SMP Fri May 30 18:29:43 UTC 2008 ia64 GNU/Linux&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;#include &lt;LINUX&gt;&lt;BR /&gt;#include &lt;SYS&gt;&lt;BR /&gt;#include &lt;PTHREAD.H&gt;&lt;BR /&gt;#include &lt;STDIO.H&gt;&lt;BR /&gt;#include &lt;STDLIB.H&gt;&lt;BR /&gt;#define NUM_THREADS     5&lt;BR /&gt;&lt;BR /&gt;void *PrintHello(void *threadid)&lt;BR /&gt;{&lt;BR /&gt;   int tid;&lt;BR /&gt;   tid = (int)threadid;&lt;BR /&gt;   printf("Hello World! It's me, thread %lu!\n", pthread_self());&lt;BR /&gt;   while(1)&lt;BR /&gt;   {&lt;BR /&gt;      sleep(4);&lt;BR /&gt;   }&lt;BR /&gt;   pthread_exit(NULL);&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;int main(int argc, char *argv[])&lt;BR /&gt;{&lt;BR /&gt;pthread_t threads[NUM_THREADS];&lt;BR /&gt;int rc, t;&lt;BR /&gt;for(t=0;t&lt;NUM_THREADS&gt;&lt;/NUM_THREADS&gt;  printf("In main: creating thread %d\n", t);&lt;BR /&gt;  rc = pthread_create(&amp;amp;threads[t], NULL, PrintHello, (void *)t);&lt;BR /&gt;  if (rc){&lt;BR /&gt;    printf("ERROR; return code from pthread_create() is %d\n", rc);&lt;BR /&gt;    exit(-1);&lt;BR /&gt;    }&lt;BR /&gt;  }&lt;BR /&gt;pthread_exit(NULL);&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;=================================&lt;BR /&gt;Output&lt;BR /&gt;In main: creating thread 0&lt;BR /&gt;In main: creating thread 1&lt;BR /&gt;Hello World! It's me, thread 2305843009225046224!&lt;BR /&gt;In main: creating thread 2&lt;BR /&gt;In main: creating thread 3&lt;BR /&gt;In main: creating thread 4&lt;BR /&gt;Hello World! It's me, thread 2305843009233434832!&lt;BR /&gt;Hello World! It's me, thread 2305843009241823440!&lt;BR /&gt;Hello World! It's me, thread 2305843009250212048!&lt;BR /&gt;Hello World! It's me, thread 2305843009258600656!&lt;BR /&gt;&lt;BR /&gt;&lt;/STDLIB.H&gt;&lt;/STDIO.H&gt;&lt;/PTHREAD.H&gt;&lt;/SYS&gt;&lt;/LINUX&gt;</description>
      <pubDate>Sun, 02 Nov 2008 03:52:53 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/what-is-thread-id-thread-t-data-type-in-ia64-platform/m-p/4298646#M62638</guid>
      <dc:creator>KRUPASINDHU PRADHAN</dc:creator>
      <dc:date>2008-11-02T03:52:53Z</dc:date>
    </item>
    <item>
      <title>Re: What is thread id thread_t data type in ia64 platform</title>
      <link>https://community.hpe.com/t5/operating-system-linux/what-is-thread-id-thread-t-data-type-in-ia64-platform/m-p/4298647#M62639</link>
      <description>Have you looked in the system and/or compiler&lt;BR /&gt;header files for a typedef?&lt;BR /&gt;&lt;BR /&gt;"sizeof" should be able to tell you the size&lt;BR /&gt;of the thing, whatever it is.&lt;BR /&gt;&lt;BR /&gt;&amp;gt; [...]  I find whenever I create thread , it&lt;BR /&gt;&amp;gt; always gives me 64-bit long int.  [...]&lt;BR /&gt;&lt;BR /&gt;How can you tell?  Counting the digits put&lt;BR /&gt;out by printf() using some format or other is&lt;BR /&gt;not a reliable method.</description>
      <pubDate>Sun, 02 Nov 2008 06:38:36 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/what-is-thread-id-thread-t-data-type-in-ia64-platform/m-p/4298647#M62639</guid>
      <dc:creator>Steven Schweda</dc:creator>
      <dc:date>2008-11-02T06:38:36Z</dc:date>
    </item>
    <item>
      <title>Re: What is thread id thread_t data type in ia64 platform</title>
      <link>https://community.hpe.com/t5/operating-system-linux/what-is-thread-id-thread-t-data-type-in-ia64-platform/m-p/4298648#M62640</link>
      <description>Hi Steven&lt;BR /&gt;&lt;BR /&gt;pthreadtypes.h file has declaretion for it.&lt;BR /&gt;/* Thread identifiers */         &lt;BR /&gt;typedef unsigned long int pthread_t;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;1. I am printing as below&lt;BR /&gt;printf("Hello World! It's me, thread %lu!\n", pthread_self());&lt;BR /&gt;&lt;BR /&gt;Above gives the numbers which can be accomordate by 64-bit. From that I concluded 64-bit&lt;BR /&gt;&lt;BR /&gt;What I want to understand is the bit/bytes of thread_id we get has special meaning. I mean its not just integer. The thred_id portray a lot information ? or its holding a memory address.</description>
      <pubDate>Sun, 02 Nov 2008 07:11:55 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/what-is-thread-id-thread-t-data-type-in-ia64-platform/m-p/4298648#M62640</guid>
      <dc:creator>KRUPASINDHU PRADHAN</dc:creator>
      <dc:date>2008-11-02T07:11:55Z</dc:date>
    </item>
    <item>
      <title>Re: What is thread id thread_t data type in ia64 platform</title>
      <link>https://community.hpe.com/t5/operating-system-linux/what-is-thread-id-thread-t-data-type-in-ia64-platform/m-p/4298649#M62641</link>
      <description>&amp;gt;May I know what exactly thread ID is in below platform type?&lt;BR /&gt;&lt;BR /&gt;Why do you need to know?  A thread_t is a thread_t and you shouldn't look any closer.&lt;BR /&gt;&lt;BR /&gt;&amp;gt;... %lu!\n", pthread_self())&lt;BR /&gt;&amp;gt;it's holding a memory address.&lt;BR /&gt;&lt;BR /&gt;You might see more by using %lx.&lt;BR /&gt;&lt;BR /&gt;&amp;gt;Steven: Have you looked in the system and/or compiler header files for a typedef?&lt;BR /&gt;&lt;BR /&gt;That's too hard.  Why not write a C++ application and use "typeid(thread_t).name()" to find out what it is.  :-)</description>
      <pubDate>Sun, 02 Nov 2008 10:47:54 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/what-is-thread-id-thread-t-data-type-in-ia64-platform/m-p/4298649#M62641</guid>
      <dc:creator>Dennis Handly</dc:creator>
      <dc:date>2008-11-02T10:47:54Z</dc:date>
    </item>
    <item>
      <title>Re: What is thread id thread_t data type in ia64 platform</title>
      <link>https://community.hpe.com/t5/operating-system-linux/what-is-thread-id-thread-t-data-type-in-ia64-platform/m-p/4298650#M62642</link>
      <description>&lt;KRUPA&gt;May I know what exactly thread ID is in below platform type?&lt;BR /&gt;&lt;BR /&gt;&lt;STEVEN&gt; Why do you need to know? A thread_t is a thread_t and you shouldn't look any closer.&lt;BR /&gt;&lt;KRUPA&gt;. I got a issue, where we have to find out is pthread_id is always covers up 64-bit. By mistake in our code we had trunacted it to 32-bit. It started dumping core when we used it in pthread_kill system call. From there investigation started, is pthread_id always covers up 64-bit ? If so , does it carry any significance like first 32-bit represents some characteristics of thread , last 32-bit some others. or pthread_id is a pointer to hold a strucutre. I am more confused, why it always gets 64-bit (full) ? Has  the kernel defined any range for it in sysctl file(I checked but did not find it).&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&amp;gt;... %lu!\n", pthread_self())&lt;BR /&gt;&amp;gt;it's holding a memory address.&lt;BR /&gt;You might see more by using %lx.&lt;BR /&gt;&lt;BR /&gt;&lt;KRUPA&gt;. Output is as below with %lu, %lx!&lt;BR /&gt;In main: creating thread 0&lt;BR /&gt;In main: creating thread 1&lt;BR /&gt;In main: creating thread 2&lt;BR /&gt;In main: creating thread 3&lt;BR /&gt;In main: creating thread 4&lt;BR /&gt;Hello World! It's me, thread 2305843009225046224, 2000000000ad38d0!&lt;BR /&gt;Hello World! It's me, thread 2305843009233434832, 20000000012d38d0!&lt;BR /&gt;Hello World! It's me, thread 2305843009241823440, 2000000001ad38d0!&lt;BR /&gt;Hello World! It's me, thread 2305843009250212048, 20000000022d38d0!&lt;BR /&gt;Hello World! It's me, thread 2305843009258600656, 2000000002ad38d0!&lt;BR /&gt;&lt;BR /&gt;&amp;lt;0a/12/1a/22/2a&amp;gt;&lt;BR /&gt;&lt;BR /&gt;Let me know if you can make out anything from %lx, Looks to me its changing in a particular pattern&lt;BR /&gt;&lt;BR /&gt;&amp;gt;Steven: Have you looked in the system and/or compiler header files for a typedef?&lt;BR /&gt;&lt;BR /&gt;That's too hard. Why not write a C++ application and use "typeid(thread_t).name()" to find out what it is. :-)&lt;BR /&gt;1.&lt;BR /&gt;printf("sizeofthread_t=%d\n", sizeof(pthread_t));&lt;BR /&gt;sizeofthread_t=8&lt;BR /&gt;&lt;BR /&gt;2.&lt;BR /&gt;#include &lt;LINUX&gt;&lt;BR /&gt;#include &lt;SYS&gt;&lt;BR /&gt;#include &lt;PTHREAD.H&gt;&lt;BR /&gt;#include &lt;STDIO.H&gt;&lt;BR /&gt;#include &lt;STDLIB.H&gt;&lt;BR /&gt;#include&lt;IOSTREAM.H&gt;&lt;BR /&gt;main()&lt;BR /&gt;{&lt;BR /&gt;cout &amp;lt;&amp;lt; "typeid of pthread_t="&amp;lt;&amp;lt; typeid(pthread_t).name() &amp;lt;&amp;lt;"\n";&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;====&lt;BR /&gt;g++ t.C -lpthread&lt;BR /&gt;./a.out&lt;BR /&gt;typeid of pthread_t=m&lt;BR /&gt;&lt;/IOSTREAM.H&gt;&lt;/STDLIB.H&gt;&lt;/STDIO.H&gt;&lt;/PTHREAD.H&gt;&lt;/SYS&gt;&lt;/LINUX&gt;&lt;/KRUPA&gt;&lt;/KRUPA&gt;&lt;/STEVEN&gt;&lt;/KRUPA&gt;</description>
      <pubDate>Sun, 02 Nov 2008 17:14:14 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/what-is-thread-id-thread-t-data-type-in-ia64-platform/m-p/4298650#M62642</guid>
      <dc:creator>KRUPASINDHU PRADHAN</dc:creator>
      <dc:date>2008-11-02T17:14:14Z</dc:date>
    </item>
    <item>
      <title>Re: What is thread id thread_t data type in ia64 platform</title>
      <link>https://community.hpe.com/t5/operating-system-linux/what-is-thread-id-thread-t-data-type-in-ia64-platform/m-p/4298651#M62643</link>
      <description>&amp;gt;is pthread_t always covers up 64-bit? ... or pthread_id is a pointer to hold a structure.&lt;BR /&gt;&lt;BR /&gt;For Linux, it looks like a pointer to the thread.  For HP-UX it isn't.&lt;BR /&gt;&lt;BR /&gt;&amp;gt;Let me know if you can make out anything from %lx, Looks to me it's changing in a particular pattern&lt;BR /&gt;&lt;BR /&gt;It looks like it is incrementing by 512 Kb, the thread control block + thread stack size?&lt;BR /&gt;&lt;BR /&gt;&amp;gt;typeid of pthread_t=m&lt;BR /&gt;&lt;BR /&gt;You need to call __cxa_demangle to get the type:&lt;BR /&gt;&lt;A href="http://www.codesourcery.com/public/cxx-abi/abi-mangling.html" target="_blank"&gt;http://www.codesourcery.com/public/cxx-abi/abi-mangling.html&lt;/A&gt;&lt;BR /&gt;&lt;A href="http://www.codesourcery.com/public/cxx-abi/abi.html#demangler" target="_blank"&gt;http://www.codesourcery.com/public/cxx-abi/abi.html#demangler&lt;/A&gt;</description>
      <pubDate>Sun, 02 Nov 2008 21:22:45 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/what-is-thread-id-thread-t-data-type-in-ia64-platform/m-p/4298651#M62643</guid>
      <dc:creator>Dennis Handly</dc:creator>
      <dc:date>2008-11-02T21:22:45Z</dc:date>
    </item>
    <item>
      <title>Re: What is thread id thread_t data type in ia64 platform</title>
      <link>https://community.hpe.com/t5/operating-system-linux/what-is-thread-id-thread-t-data-type-in-ia64-platform/m-p/4298652#M62644</link>
      <description>The old linuxthreads implementation used a pthread_t that was an index into an array.  It tended to be a small number.&lt;BR /&gt;&lt;BR /&gt;The more current NPTL linux threads provided by hpde 2.0 use a pthread_t that is a pointer to a struct.&lt;BR /&gt;&lt;BR /&gt;You certainly need to preserve the full size of a pthread_t to reliably use it with pthread_kill.  The high 32 bits of the pthread_t cannot be expected to have a predictable value.  And a later implementation might use a pthread_t with an even larger type.  As noted in "man pthread_equal", the pthread_t type could be a structure in some implementations.</description>
      <pubDate>Mon, 03 Nov 2008 17:37:27 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/what-is-thread-id-thread-t-data-type-in-ia64-platform/m-p/4298652#M62644</guid>
      <dc:creator>Mike Stroyan</dc:creator>
      <dc:date>2008-11-03T17:37:27Z</dc:date>
    </item>
  </channel>
</rss>

