LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 10-02-2007, 05:13 AM   #1
vdx
Member
 
Registered: Aug 2007
Location: The Greate INDIA
Distribution: CentOS, RHEL, Fedora
Posts: 102

Rep: Reputation: 24
Question thread id


hi frnds,

I am new to threads in linux, so for learning threads from begining I have downloaded a tutorial and start working on it.

pthread_create()
function, requires 4 args, among tht first argument is id of new thread. I have stored tht id into a var t_id (of type pthread_t).

Wen I print the t_id, its a 10 digit negative value.

I am not surprizing with the 10 digits but wy it is negative ??

as per my knowledge in unix any descriptor is non-negative int values.

then wy thread ids are not positive integers ?

is there any specific reason ?
 
Old 10-02-2007, 09:57 AM   #2
XavierP
Moderator
 
Registered: Nov 2002
Location: Kent, England
Distribution: Debian Testing
Posts: 19,192
Blog Entries: 4

Rep: Reputation: 475Reputation: 475Reputation: 475Reputation: 475Reputation: 475
Moved: This thread is more suitable in Programming and has been moved accordingly to help your thread/question get the exposure it deserves.
 
Old 10-02-2007, 11:46 AM   #3
paulsm4
LQ Guru
 
Registered: Mar 2004
Distribution: SusE 8.2
Posts: 5,863
Blog Entries: 1

Rep: Reputation: Disabled
Posix thread IDs are "integral" (including, but not necessarily limited to, "signed integers"). It's perfectly OK for the high (sign) bit to be set; it's perfectly OK for you to "printf ()" the thread handle ("opaque handle" - *not* a number, certainly not a Unix file descriptor!) with "%u" or "0x%x" if you don't want to see a negative value ("printf()", or whatever equivalent you prefer):

http://publib.boulder.ibm.com/infoce...s/glossary.htm

'Hope that helps .. PSM

PS:
Why go to the effort to abbreviate "why"?
 
  


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
Thread Scheduling using POSIX THREAD rameshtekumudi Programming 3 09-01-2006 10:47 AM
[thread control suggestion] add a "solved" button that the thread starter can click atom LQ Suggestions & Feedback 3 03-24-2005 11:55 AM
Main thread sending notification to child thread rajesh_b Programming 1 09-22-2004 09:15 AM
'Last Thread' 'Next Thread' for 0 Replies and new posts darin3200 LQ Suggestions & Feedback 2 08-16-2004 01:02 PM
configure qt thread issue (just compiled qt w/ -thread option) cleff Linux - Software 8 05-07-2004 11:11 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 08:11 AM.

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