- Community Home
- >
- Servers and Operating Systems
- >
- Operating System - Linux
- >
- General
- >
- What is thread id thread_t data type in ia64 platf...
-
- Forums
-
- Advancing Life & Work
- Advantage EX
- Alliances
- Around the Storage Block
- HPE Ezmeral: Uncut
- OEM Solutions
- Servers & Systems: The Right Compute
- Tech Insights
- The Cloud Experience Everywhere
- HPE Blog, Austria, Germany & Switzerland
- Blog HPE, France
- HPE Blog, Italy
- HPE Blog, Japan
- HPE Blog, Middle East
- HPE Blog, Latin America
- HPE Blog, Russia
- HPE Blog, Saudi Arabia
- HPE Blog, South Africa
- HPE Blog, UK & Ireland
-
Blogs
- Advancing Life & Work
- Advantage EX
- Alliances
- Around the Storage Block
- HPE Blog, Latin America
- HPE Blog, Middle East
- HPE Blog, Saudi Arabia
- HPE Blog, South Africa
- HPE Blog, UK & Ireland
- HPE Ezmeral: Uncut
- OEM Solutions
- Servers & Systems: The Right Compute
- Tech Insights
- The Cloud Experience Everywhere
-
Information
- Community
- Welcome
- Getting Started
- FAQ
- Ranking Overview
- Rules of Participation
- Tips and Tricks
- Resources
- Announcements
- Email us
- Feedback
- Information Libraries
- Integrated Systems
- Networking
- Servers
- Storage
- Other HPE Sites
- Support Center
- Aruba Airheads Community
- Enterprise.nxt
- HPE Dev Community
- Cloud28+ Community
- Marketplace
-
Forums
-
Blogs
-
Information
-
English
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
11-01-2008 08:52 PM
11-01-2008 08:52 PM
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.
I read some topic in google, that thread ID is just not a long int, it can be pointer or structure .
May I know what exactly thread ID is in below platform type ?
Linux Node2 2.6.10-telco-1.46-mckinley-smp #1 SMP Fri May 30 18:29:43 UTC 2008 ia64 GNU/Linux
#include
#include
#include
#include
#include
#define NUM_THREADS 5
void *PrintHello(void *threadid)
{
int tid;
tid = (int)threadid;
printf("Hello World! It's me, thread %lu!\n", pthread_self());
while(1)
{
sleep(4);
}
pthread_exit(NULL);
}
int main(int argc, char *argv[])
{
pthread_t threads[NUM_THREADS];
int rc, t;
for(t=0;t
rc = pthread_create(&threads[t], NULL, PrintHello, (void *)t);
if (rc){
printf("ERROR; return code from pthread_create() is %d\n", rc);
exit(-1);
}
}
pthread_exit(NULL);
}
=================================
Output
In main: creating thread 0
In main: creating thread 1
Hello World! It's me, thread 2305843009225046224!
In main: creating thread 2
In main: creating thread 3
In main: creating thread 4
Hello World! It's me, thread 2305843009233434832!
Hello World! It's me, thread 2305843009241823440!
Hello World! It's me, thread 2305843009250212048!
Hello World! It's me, thread 2305843009258600656!
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
11-01-2008 11:38 PM
11-01-2008 11:38 PM
Re: What is thread id thread_t data type in ia64 platform
header files for a typedef?
"sizeof" should be able to tell you the size
of the thing, whatever it is.
> [...] I find whenever I create thread , it
> always gives me 64-bit long int. [...]
How can you tell? Counting the digits put
out by printf() using some format or other is
not a reliable method.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
11-02-2008 12:11 AM
11-02-2008 12:11 AM
Re: What is thread id thread_t data type in ia64 platform
pthreadtypes.h file has declaretion for it.
/* Thread identifiers */
typedef unsigned long int pthread_t;
1. I am printing as below
printf("Hello World! It's me, thread %lu!\n", pthread_self());
Above gives the numbers which can be accomordate by 64-bit. From that I concluded 64-bit
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
11-02-2008 02:47 AM
11-02-2008 02:47 AM
SolutionWhy do you need to know? A thread_t is a thread_t and you shouldn't look any closer.
>... %lu!\n", pthread_self())
>it's holding a memory address.
You might see more by using %lx.
>Steven: Have you looked in the system and/or compiler header files for a typedef?
That's too hard. Why not write a C++ application and use "typeid(thread_t).name()" to find out what it is. :-)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
11-02-2008 09:14 AM
11-02-2008 09:14 AM
Re: What is thread id thread_t data type in ia64 platform
>... %lu!\n", pthread_self())
>it's holding a memory address.
You might see more by using %lx.
In main: creating thread 0
In main: creating thread 1
In main: creating thread 2
In main: creating thread 3
In main: creating thread 4
Hello World! It's me, thread 2305843009225046224, 2000000000ad38d0!
Hello World! It's me, thread 2305843009233434832, 20000000012d38d0!
Hello World! It's me, thread 2305843009241823440, 2000000001ad38d0!
Hello World! It's me, thread 2305843009250212048, 20000000022d38d0!
Hello World! It's me, thread 2305843009258600656, 2000000002ad38d0!
<0a/12/1a/22/2a>
Let me know if you can make out anything from %lx, Looks to me its changing in a particular pattern
>Steven: Have you looked in the system and/or compiler header files for a typedef?
That's too hard. Why not write a C++ application and use "typeid(thread_t).name()" to find out what it is. :-)
1.
printf("sizeofthread_t=%d\n", sizeof(pthread_t));
sizeofthread_t=8
2.
#include
#include
#include
#include
#include
#include
main()
{
cout << "typeid of pthread_t="<< typeid(pthread_t).name() <<"\n";
}
====
g++ t.C -lpthread
./a.out
typeid of pthread_t=m
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
11-02-2008 01:22 PM
11-02-2008 01:22 PM
Re: What is thread id thread_t data type in ia64 platform
For Linux, it looks like a pointer to the thread. For HP-UX it isn't.
>Let me know if you can make out anything from %lx, Looks to me it's changing in a particular pattern
It looks like it is incrementing by 512 Kb, the thread control block + thread stack size?
>typeid of pthread_t=m
You need to call __cxa_demangle to get the type:
http://www.codesourcery.com/public/cxx-abi/abi-mangling.html
http://www.codesourcery.com/public/cxx-abi/abi.html#demangler
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
11-03-2008 09:37 AM
11-03-2008 09:37 AM
Re: What is thread id thread_t data type in ia64 platform
The more current NPTL linux threads provided by hpde 2.0 use a pthread_t that is a pointer to a struct.
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.
Hewlett Packard Enterprise International
- Communities
- HPE Blogs and Forum
© Copyright 2021 Hewlett Packard Enterprise Development LP