LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 11-01-2008, 10:57 PM   #1
kspradhan
LQ Newbie
 
Registered: Aug 2008
Posts: 8

Rep: Reputation: 0
What is thread id thread_t data type in ia64 platform


Hi,
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 <linux/unistd.h>
#include <sys/types.h>
#include <pthread.h>
#include <stdio.h>
#include <stdlib.h>
#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<NUM_THREADS;t++){
printf("In main: creating thread %d\n", 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!

Thanks
Krupa
 
Old 11-03-2008, 07:43 AM   #2
pinniped
Senior Member
 
Registered: May 2008
Location: planet earth
Distribution: Debian
Posts: 1,732

Rep: Reputation: 50
see in the includes: bits/pthreadtypes.h

In my case (AMD64) I have:

Code:
/* Thread identifiers.  The structure of the attribute type is not
   exposed on purpose.  */
typedef unsigned long int pthread_t;
[edit]

With GCC, 'long' may be 32 or 64 bits, depending on the architecture you compile for. With the AMD64 for example, a 32-bit (x86) compile will give a 32-bit 'long' while a native 64-bit compile gives a 64-bit long. Since IA64 is a 64-bit machine, I would expect 'long' to be 64-bit, so if you have the same declaration of pthread_t in that file mentioned, then you're dealing with a thread id which is a 64-bit unsigned integer.

Last edited by pinniped; 11-03-2008 at 07:48 AM.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
how can we initialsed the enum type of varible in thread in LINUX o.s. nagendrar Programming 1 05-08-2008 09:11 AM
Setting data breakpoints in a program on x86 platform yprasanth Linux - General 0 04-14-2006 12:13 AM
Web browsing - True Type font thread DrD Linux - Software 5 10-31-2004 03:39 AM
hardware name/platform/CPU type? chinmay nautiya Linux - Software 2 08-19-2003 06:47 AM
Data Type 9 bob Linux - Newbie 1 02-10-2001 08:10 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 12:37 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration