LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   thread id (https://www.linuxquestions.org/questions/programming-9/thread-id-588836/)

vdx 10-02-2007 05:13 AM

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 ?

XavierP 10-02-2007 09:57 AM

Moved: This thread is more suitable in Programming and has been moved accordingly to help your thread/question get the exposure it deserves.

paulsm4 10-02-2007 11:46 AM

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"?


All times are GMT -5. The time now is 04:39 PM.